Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Passing a string as a parameter

Author  Topic 

agarwasa2008
Posting Yak Master

109 Posts

Posted - 2009-11-03 : 13:19:35
@SelectFields is really a string of product names for ex. 'name1','name2','name3'. Is this the right way to write this query.



CREATE PROCEDURE dbo.getInfo
@id int = 0,
@SelectFields nvarchar(MAX)
AS

SELECT *
from table1
where (id=@id) and name in (@SelectFields)

SA

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-11-03 : 13:25:22
Nope, not the "in (@selectfields) parts Search this site for Parsing techniques "Parse Values"

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-04 : 02:03:22
http://www.sommarskog.se/arrays-in-sql-2005.html


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -