Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
sql queryselect AuditCategoryName from IS_AuditCategory where AuditCategoryId in(select CheckListCategoryIds from IS_AuditChecklistProjectScope where IS_AuditChecklistProjectScope.[PrimaryProjectScopeId ] =2)Error---Conversion failed when converting the varchar value '46,48,43,45,44' to data type int.sabari
bandi
Master Smack Fu Yak Hacker
2242 Posts
Posted - 2012-12-14 : 00:39:59
Try this...
select AuditCategoryName from IS_AuditCategory t1JOIN (select CheckListCategoryIds from IS_AuditChecklistProjectScope where IS_AuditChecklistProjectScope.[PrimaryProjectScopeId]=2 )t2ON ','+CheckListCategoryIds+',' LIKE '%,'+CAST(AuditCategoryId as varchar(30))+',%'
Let me know the result--Chandu
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2012-12-14 : 02:32:37
or use a string parsing UDF to get values onto a table and then join to that
DECLARE @CategoryIDs varchar(8000)select @CategoryIDs=CheckListCategoryIds from IS_AuditChecklistProjectScope where IS_AuditChecklistProjectScope.[PrimaryProjectScopeId]=2select AuditCategoryName from IS_AuditCategory t1JOIN dbo.ParseValues(@CategoryIDs,',') fON f.Val = t1.AuditCategoryId ParseValues can be found in below linkhttp://visakhm.blogspot.in/2010/02/parsing-delimited-string.html
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/