SQLParamter setting.

  • Thread starter Thread starter Archana
  • Start date Start date
A

Archana

Hi all,

i am having query which is using in operator and there i want to pass
integetvalue.

say like select * from employee where empid in(1,2,3);

here empid i have to pass dynamically so how will i use sqlparameter
for this?

please help me asap.

thanks in advance.
 
Archana,

As far as I know, there is no straightforward way to use parameters in this
situation.

Kerry Moorman
 
Again, this is a very common question so a little Googling will help find a
number of solutions.
As you have discovered, the IN expression won't take a parameter, but it
will take a table reference as in

... WHERE X IN (SELECT y FROM MyTable)

To this end you need to create a table to pass to the IN expression. The
trick is to create a table from the delimited string (1,2,3) of acceptable
values. I show how to do this with a CLR function as well as a TSQL
table-valued function in my book...

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
 
Back
Top