Prev: determining what week i'm in
Next: Can you improve this TSQL: I am converting DATETIME to CHAR()
From: Luigi on 5 Feb 2010 04:18 Hi all, having a variable with values separated by ; how can I split it to execute a stored procedure for each of them? Like declare @MyVariable varchar(50) set @MyVariable = 'value1;value2;value3' and exec MyStored for each of value1, value2, value3, etc. Thanks a lot. Luigi
From: Hugo Kornelis on 5 Feb 2010 06:52 On Fri, 5 Feb 2010 01:18:01 -0800, Luigi wrote: >Hi all, >having a variable with values separated by ; >how can I split it to execute a stored procedure for each of them? > >Like > >declare @MyVariable varchar(50) >set @MyVariable = 'value1;value2;value3' > >and exec MyStored for each of value1, value2, value3, etc. > >Thanks a lot. > >Luigi Hi Luigi, See http://www.sommarskog.se/arrays-in-sql.html -- Hugo Kornelis, SQL Server MVP My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
From: Luigi on 5 Feb 2010 09:34 "Hugo Kornelis" wrote: > Hi Luigi, > > See http://www.sommarskog.se/arrays-in-sql.html Thank you Hugo, it's a good starting point. Luigi
From: Plamen Ratchev on 5 Feb 2010 09:43 Instead of splitting the variable you can design the stored procedure to take a table-valued parameter (on SQL Server 2008) or XML, and process all values at once (instead of multiple SP executions). -- Plamen Ratchev http://www.SQLStudio.com
From: Luigi on 8 Feb 2010 10:58 "Plamen Ratchev" wrote: > Instead of splitting the variable you can design the stored procedure to take a table-valued parameter (on SQL Server > 2008) or XML, and process all values at once (instead of multiple SP executions). Hi Plamen, unfortunately I must adhere at SQL Server 2000 T-SQL specifications. Luigi
|
Next
|
Last
Pages: 1 2 Prev: determining what week i'm in Next: Can you improve this TSQL: I am converting DATETIME to CHAR() |