Monthly Archives: December 2009

SMO and Adhoc Queries

Start SQL Profiler, chose SQL:BatchCompleted event only and set filter on TextData to ‘%product%’. In SSMS, go to AdventureWorks database, right click Production.Product table–>Script Table as –>Create to–>Clipboard. Go back SQL profiler, you will find 23 adhoc calls sent to … Continue reading

Posted in SQL Server 2005 SMO | Leave a comment

ORDER BY and CASE Expression

/* We can use CASE expression in ORDER BY clause. This is useful if a stored procedure has parameters from client side to specify ordering column and direction, e.g.: */ USE AdventureWorks GO DECLARE @SortOrder nvarchar(5), @OrderBy sysname; SELECT @SortOrder=N‘ASC’, … Continue reading

Posted in SQL server 2005 | Leave a comment