We just want to delay our query for one min.
To achieve that one we need write the below script
print getdate()
waitfor delay '00:01'
print getdate()
Output:
Mar 19 2010 6:37PM
Mar 19 2010 6:38PM
Happy Querying
Friday, March 19, 2010
Sleep for 1 min in SQL SERVER 2005
Posted by Kumar at 6:43 AM 0 comments
Labels: SQL
Multiple Columns as Primary Key - SQL Server 2005
Steps to make multiple Columns of a table in SQL Server Management Studio
- Go to Table Design.
- Select a Column first to define it as Primary key.
- To select multiple columns, hold down the CTRL key while you click the other columns.
- Right-click the row selector for the column and select Set Primary Key.
- A primary key index, named "PK_" followed by the table name is automatically created.
Happy Coding
Posted by Kumar at 5:52 AM 0 comments
Labels: SQL
Wednesday, March 17, 2010
Update Tables Using Inner Join
You will come across the problem to update a table with the help of joining two tables.
Below is the steps to update a table using joins
- Perform a update say UPDATE
- Join the tables with condition say FIRSTTABLE AS A INNER JOIN SECONDTABLE AS B ON A.FIELDNAME = B.FIELDNAME
- Write the condition which is going to change or update say SET A.FIELDNAME=2, B.FIELDNAME=5
- If you have a where condition then add it say WHERE A.FIELDNAME=10
UPDATE
FIRSTTABLE AS A INNER JOIN SECONDTABLE AS B
ON A.FIELDNAME = B.FIELDNAME
SET A.FIELDNAME=2, B.FIELDNAME=5
WHERE A.FIELDNAME=10
Simply cool
Hope this helped you.
Happy Coding,
Kumar
Posted by Kumar at 5:15 AM 0 comments
Labels: SQL
Thursday, November 26, 2009
SQL Database Offline / Online
If the user wants to make the database offline or online below are the commands.
First Method:
To make database offline use the below query
ALTER DATABASE [Database name] SET OFFLINE
To make database online use the below query
ALTER DATABASE [Database name] SET ONLINE
Second Method:
User can also right click on the Database and select Tasks->Take Offline
select Tasks->Brink online for making Database to Online
Posted by Kumar at 5:53 AM 0 comments
Labels: SQL