• Jeff Moden (10/3/2013)


    Steve Smith-163358 (10/3/2013)


    Thank you all very much for your replies, and thank you Jeff for the excellent article that Alan linked to earlier.

    I had often read about the merits of set based v's cursors before, but never really grasped the concepts.

    More to the point, I didn't realise that half of the code I wrote was set based and half wasn't 🙂

    Alan, thank you for the code sample.

    I've tried using it, but unfortunately I start hitting limits with the size of the data type.

    In my test example that I'm using, I have 10,000 tables that I want to delete.

    It appears, that due to the number of tables, I can't populate them all into the parameter, even using varchar(max)

    With this many tables, I may be stuck with cursors or similar procedures

    I don't believe that you're hitting the limits of the datatype (VARCHAR(MAX)). What you are hitting the limit of is how to display the code... normally 8K bytes (or less depending on your column width settings) even if the variable contains much more.

    Good point Jeff....

    Steve... can you post the original error that you were receiving when you thought you hit the limit of the varchar(max)? Thanks.

    Kurt

    Kurt W. Zimmerman
    SR DBA
    Lefrak Organization
    New York, NY

    http://www.linkedin.com/in/kurtwzimmerman