Home Forums SQL Server 2008 SQL Server 2008 - General Passing comma separated values for IN list in DELETE statement from SQLCMD RE: Passing comma separated values for IN list in DELETE statement from SQLCMD

  • CELKO (9/11/2012)


    I have a two articles on this topic at Simple Talk. There is no need to throw away performance, maintainabilty and portability to do this.

    http://www.simple-talk.com/sql/learn-sql-server/values()-and-long-parameter-lists/

    http://www.simple-talk.com/sql/learn-sql-server/values()-and-long-parameter-lists---part-ii/

    If portability to another DBMS is a concern then the methods Joe discusses are a good solution.

    On the other hand, if you don't see yourself switching to another DBMS in the near future and you want to keep your maintenance a lot simpler then you might be better off following the ideas that Craig has suggested. For me, I am a sql server guy and I don't really worry about portability. I also don't want to have to alter my procedure and redeploy my data access tier every time I need to make the list longer.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/