34,590
社区成员
发帖
与我相关
我的任务
分享
use northwind
exec sp_executesql N'select * from customers where customerid in (''ALFKI'',''ANATR'')'
use northwind
exec sp_executesql N'select * from customers where customerid in (@customerid)'
,N'@customerid varchar(8000)',@customerid='ALFKI'',''ANATR'
DECLARE @sql nvarchar(max)
DECLARE @customerid nvarchar(max)
SET @customerid=N'''ALFKI'',''ANATR'''
SET @sql = N'select * from customers where customerid in ('+@customerid+N')'
--PRINT @sql
exec sp_executesql @sql
DECLARE @customerid VARCHAR(8000)
SET @customerid='ALFKI'',''ANATR'
select * from customers where customerid in (@customerid)
EXEC sp_executesql N'SELECT top 2 * FROM sys.all_objects where Name IN(@Names)',N'@Names NVARCHAR(200)',@Names='sysrscols'
DECLARE @Sql NVARCHAR(max)
SET @Sql=N'select * from customers where customerid in ('''+'ALFKI'',''ANATR'+''')'
exec sp_executesql @Sql
exec sp_executesql N'select * from customers where customerid in (@customerid1,@customerid2)',
N'@customerid1 varchar(8000),@customerid2 varchar(8000)',
@customerid1='ALFKI',
@customerid2='ANATR'