新手求助,十万火急!!!!!!
declare @sBClassID varchar(2),@sSearchValue varchar(100),@sSearchKey varchar(10),@sql varchar(200)
set @sBClassID= '01 '
set @sSearchValue= '%c% '
set @sSearchKey= 'Book_Name '
set @sql = 'select a.*,b.Pub_Name from T_Books a,T_Publishers b
where a.Pub_ID=b.Pub_ID and a.BClass_ID= '+ @sBClassID+ ' and '+ @sSearchKey + ' like '+ @sSearchValue +
' order by a.Book_AddDate desc '
exec (@sql)
请问怎么样可以解决
------解决方案--------------------declare @sBClassID varchar(2),@sSearchValue varchar(100),@sSearchKey varchar(10),@sql varchar(200)
set @sBClassID= '01 '
set @sSearchValue= '%c% '
set @sSearchKey= 'Book_Name '
set @sql = 'select a.*,b.Pub_Name from T_Books a,T_Publishers b
where a.Pub_ID=b.Pub_ID and a.BClass_ID= '+ @sBClassID+ ' and '+ @sSearchKey + ' like ' ' '+ @sSearchValue +
' ' ' order by a.Book_AddDate desc '
exec (@sql)