I have a problem in using a variable in sql querydeclare @var nvarchar(100)SET @var = 'SMTRKBASE,SMTRFAQ,SMTRSME'SET @var = '''' + replace(@var,',',''',''') + ''''print @varSELECT * FROM STSOut_Unicode WHERE FileType in (SELECT ID FROM tblSiteMetricsFileType where TxtID in (@var))
The query is not giving me any result at all, it looks like the variable @var is not getting substituted properly.Why is this so.whats the correct way of using a variable in a query.I want to avoid dynamic sql.