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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Delimitted string in vs Table values in

Author  Topic 

kalluri_nb
Starting Member

7 Posts

Posted - 2008-09-11 : 02:39:10
Hi

I've a big set of reference ID comming in as comma delimitted string ex: 1,2,3,4,5.... which I'm using to build a dymanic SQL statement for using it in 'ID in ('+@CSV+')" format. But at some times I get an exception as the string is being truncated due to NVarchar's 4000 length limitation. Now I'm parsing the string into a table with column ID and using the subquery approach to check the "in" condition. I've a doubt which of these approaches is performance wise suggested.


Regards,
Narotham

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-11 : 02:48:29
quote:
NVarchar's 4000 length limitation

then use nvarchar(max)


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

kalluri_nb
Starting Member

7 Posts

Posted - 2008-09-11 : 03:04:20
Will the dynamic sql perform faster than the statement involving subquery

Regards,
Narotham
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-11 : 04:02:26
why don't you try it out and see which is faster ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -