DECLARE @m_LastName nvarchar(20)
DECLARE @Sql varchar(256)
SET @m_LastName = 'Fuller'
SET @Sql = 'SELECT * FROM Employees WHERE LastName='+ char(39) + @m_LastName + char(39)
EXEC(@Sql)
加上char(39)就可以了。
转载于:https://my.oschina.net/gaopeng8/blog/186097