|
-
Apr 6th, 2005, 08:20 AM
#1
Re: Copy DB to another DB
 Originally Posted by dannywooly
LOL i spent 2 hours learning TSQL to do that loop, and you do it in 3 lines LOL Cheers mate 
In general CURSORS are considered not set-based logic and should be avoided.
Then again, executing a dynamic SQL string is considered bad practice also.
But in your case - needing to do "system" cleanup/DBA work means you can ignore those two rules - you could use the CURSOR or use the dynamic SQL - both fit the bill in this case.
It's good to know both techniques - the SELECT @SQL=... "loop" that Asgorath posted is a very nice trick that can be used for all kinds of purposes.
As far as I'm concerned, if I can take a mainframe BASIC program calculation and get it into T-SQL and it requires a cursor to pull it off, I've still made a huge leap towards getting all my business logic into the database.
So, in the end, cursors are not so bad - just make sure they are required to pull of the end goal, and not that it's simply easier to think in the sequential processing model as opposed to the SQL set-based processing model.
Have I talked too much yet?
-
Apr 6th, 2005, 08:30 AM
#2
Thread Starter
Hyperactive Member
Re: Copy DB to another DB
 Originally Posted by szlamany
In general CURSORS are considered not set-based logic and should be avoided.
Then again, executing a dynamic SQL string is considered bad practice also.
But in your case - needing to do "system" cleanup/DBA work means you can ignore those two rules - you could use the CURSOR or use the dynamic SQL - both fit the bill in this case.
It's good to know both techniques - the SELECT @SQL=... "loop" that Asgorath posted is a very nice trick that can be used for all kinds of purposes.
As far as I'm concerned, if I can take a mainframe BASIC program calculation and get it into T-SQL and it requires a cursor to pull it off, I've still made a huge leap towards getting all my business logic into the database.
So, in the end, cursors are not so bad - just make sure they are required to pull of the end goal, and not that it's simply easier to think in the sequential processing model as opposed to the SQL set-based processing model.
Have I talked too much yet? 
Its all good mate, im a learner and like new information, i have learnt loads this morning trying to fumble through these techniques!
Cheers All
have a good day
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|