Results 1 to 12 of 12

Thread: Copy DB to another DB

Hybrid View

  1. #1
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Copy DB to another DB

    Quote 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?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2003
    Posts
    263

    Re: Copy DB to another DB

    Quote 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
  •  



Click Here to Expand Forum to Full Width