SQL tips

 How to Avoid cursors:

http://www.code-magazine.com/Article.aspx?quickid=060113

USE AdventureWorks
GO
DECLARE @TransactionID int
, @TransactionType nchar(1)
, @Quantity int

SET @TransactionID = (SELECT MIN(TransactionID)¼br> FROM Production.TransactionHistory)
WHILE @TransactionID IS NOT NULL
BEGIN
SET @TransactionID = (SELECT MIN(TransactionID)¼br> FROM Production.TransactionHistory WHERE TransactionID > @TransactionID)
END

UPDATE FROM syntax : From one table to another..

http://sqlblog.com/blogs/hugo_kornelis/archive/2008/03/10/lets-deprecate-update-from.aspx

Posted by admin on Jun 25 2009 in SQLServer

No Responses to “SQL tips”

Leave a Reply

You must be logged in to post a comment.