I have a SQL statement like the following:
... const string sql = @"UPDATE PLATYPUS SET DUCKBILLID = :NEWDUCKBILLID WHERE PLATYPUSID IN (:ListOfInts)"; ... ocmd.Parameters.Add("ListOfInts", ??WhatNow??);
How can I provide the comma separated list of ints, which could be any (reasonable*) number of values
CREATE FUNCTION dbo. SplitInts ( @List VARCHAR(MAX), @Delimiter VARCHAR(255) ) RETURNS TABLE AS RETURN ( SELECT Item = CONVERT(INT, Item) FROM ( SELECT Item = x.i.value('(./text())[1]', 'varchar(max)') FROM ( SELECT [XML] = CONVERT(XML, '<i>' + REPLACE(@List, @Delimiter, '</i><i>') + '</i>'). query('.
You can create lists of SQL Query or Fixed Data values . In the Data Model components pane, click List of Values and then click Create new List of Values. Enter a Name for the list and select a Type.
You can't, you have to create some helper function that replaces :ListOfInts
with ( for example ) :I0,:I1,:I2...
and pass the parameter by adding one by one in code. The function you want is gracefully emulated by Dapper.Net in its list support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With