Unlimited Web Space

Enjoy Unlimited web hosting

Nov 7, 2011

The fastest way to Copy a table with a million rows from one database to another in SQL Server.

I have been working with SQL Server in most of my career, many consequences arise when we need to backup a large database, or merge two large database into a single database. The question here is not how it is done? but the question is what is the fastest way to do it?

To backup a whole database:
The slower way: you can use the 'backup database' wizard from SQL-Server
        you can use the 'Copy database' wizard

How to declare a SQL query and execute it in SQL Server

Sometimes consequences arise in which you need to declare a query and execute it a number of times when you are working in SQL Server or any Server in SQL. There are store procedures that requires a query to be declared and execute it under some loop or even in an if else statement.

How to use a 'while' loop in sql server.

In sql server, 'while' loop is the most used loop and the most popular loop. Most programers also use it in stead of a 'for' loop. Suppose, you need to do a task for n number of times like, 'while' loop is successfully used:

The 'while' loop syntax in sql is:

Nov 3, 2011

How to put comma(,) seperations in a large numeric value of SQL Server Database using select statement?

inserting commas in number SQL
 Suppose you have a large numeric value that you want to make more readable in SQL select query, that is, you have 1000000000 numeric data and you want to display it as 1,000,000,000.00 or may be just 1,000,000,000 if it is not a money. It can be easily done in SQL Server by joining two/three functions: CAST and CONVERT and PARSENAME

1. How can I CAST a string (nvarchar datatype) from a database table as integer?

string into integer

If you want to string datatype into integer using SQL Server. You can CAST an nvarchar datatype from a table (any other datatype too) into integer by first using the ROUND function as long as the data is a number. You can also CAST an expression within codes in SQL Server into integer as long as they are numeric values or numbers.