Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing in Multiple complex PKs to Stored Procedure
Message
 
 
To
29/12/2015 07:45:36
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Environment versions
SQL Server:
SQL Server 2012
Application:
Desktop
Miscellaneous
Thread ID:
01629332
Message ID:
01629377
Views:
25
Hi Frank,

I've checked one of the SPs and in that SP we're passing info like this

Id,Quantity, DateTime;Id,Quantity,DateTime as varchar(max) string. For that we're using the following:
with  cteSource ( Data )
              as ( select  cast('<v><i>' + replace(replace(@cMbRedemptions, ';', '</i></v><v><i>'), ',', '</i><i>') +
                           '</i></v>' as xml) as Data
                 )
         insert   into #tblRedemptions
                  ( BenefitID,
                    Quantity,
                    Date_Time )
                  select   v.value('i[1]', 'INT') as BenefitID,
                           v.value('i[2]', 'INT') as Quantity,
                           v.value('i[3]', 'datetime') as Date_Time
                  from     cteSource as s
                           cross apply Data.nodes('v') as n ( v ) ;
I can check other samples as I know we do use XML in a few cases, I just need to recall where.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform