Hi,
I have a string array.
Example:
string[] test =new string[3] {"abc,def", "ghy,spd", "xyz,uni"};
How can put this array in sql where clause:
My final output query should like this:
Select *
from tableName
where id in ('abc', 'def', 'ghy', 'spd', 'xyz', 'uni');
Thanks,
Darma
Loading
VulpesPosted Dec 16, 2013, 10:56 AM
The output is:
Select * from tableName where id in ('abc', 'def', 'ghy', 'spd', 'xyz', 'uni');
Jignesh TrivediPosted Dec 16, 2013, 11:25 PM
Same as insert you can use this as select also
like
In stored procedure I am using...
INSERT INTO CUSTOMER (CustomerId,CustomerName ,Isdeleted )
SELECT CustomerId, CustomerName, 0 AS Isdeleted FROM @TempTable
Instead of you can write like
Select * from Customer
where CustomerId in (select Customerid from @TempTable)
hope this will help you.
darma tejaPosted Dec 16, 2013, 8:33 AM
Thanks for the reply.
I have gone through the articles, All those articles explains about inserting the data.
But I want to retrieve the data.
Darma
Jignesh TrivediPosted Dec 16, 2013, 5:47 AM
In this case you can use table value parameter
Please refer my article
http://www.c-sharpcorner.com/UploadFile/ff2f08/table-valued-parameter-in-sql-server-2008/
http://www.c-sharpcorner.com/UploadFile/ff2f08/table-value-parameter-use-with-C-Sharp/
hope this will help you.