sql server - How to Concat String in SQL WHERE clause -


i have declared 2 variables in raw sql

declare @str nvarchar(max), @str1 nvarchar (max);  set @str = "  , (c.bondsales_confirmed <> -1)";  set @str1 = "  , (c.bondsales_issuetype = 'regular')"; 

my sql query is:

select * t_bondsales (bondsales_ctype <> 'institute') " + str1 + str  " 

here following error:

error: sql problems: incorrect syntax near "+ str1 + str"

can 1 please me proper syntax how concat string in clause?

try 1 -

declare         @str nvarchar(max)      , @str1 nvarchar (max);  select         @str = ' , c.bondsales_confirmed != -1'      , @str1 = ' , c.bondsales_issuetype = ''regular''';  declare @sql nvarchar(max)  select @sql = ' select *  t_bondsales  bondsales_ctype != ''institute'''      + @str       + @str1  print @sql exec sys.sp_executesql @sql 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -