exec执行的问题,急
CREATE PROCEDURE test
@Condition varchar(100)
AS
declare @sql nvarchar(400)
set @sql='select * from student where Sdept='+@Condition
print(@sql)
exec(@sql)
GO
如上存储过程,执行的时候有错误,用print打出来是例如
select * from student where Sdept=MA
这样的,我想的得到
select * from student where Sdept=‘MA’
这样的@sql串该怎么改啊,谢谢