Tagged Questions
7
votes
2answers
222 views
Why does this cursor produce results in the incorrect order?
I am writing some dynamic SQL to identify and, perhaps if I'm feeling crazy enough, automatically convert my NONCLUSTERED indexes into CLUSTERED indexes.
The line ORDER BY 1,2,3 DESC; in the SQL ...
7
votes
2answers
2k views
Create View in specified database with dynamic sql?
I am writting a dynamic sql to drop and create view in different database.
So I wrote:
set @CreateViewStatement =
'
USE ['+ @DB +'];
CREATE VIEW ...