--方式一:
DECLARE @tempEmpID INT,@sql NVARCHAR(4000)
SET @tempEmpID=4
SET @sql=N'Select * from Orders where EmployeeID='+CAST(@tempEmpID AS NVARCHAR(4))
EXEC sp_executesql @sql
GO
--方式二:
DECLARE @tempEmpID INT,@sql NVARCHAR(4000)
SET @tempEmpID=4
SET @sql=N'Select * from Orders where EmployeeID=@tempEmpID'
EXEC sp_executesql @sql,N'@tempEmpID INT',@tempEmpID=4
这两种方式有什么区别呢?那种更高效,安全呢??