日期:2014-05-16 浏览次数:20478 次
declare @a varchar(20),@sql varchar(200)
set @sql=N'select'+ @a+'='+'Phone from House where Phone=''13902273189'''
exec(@sql)
select @a
--Phone是表的字段 :这段代码要怎么写,@a输出才有值 ? N'select'+ @a+'='+'Phone from House where Phone=''13902273189'''
declare @a varchar(20),@sql nvarchar(200)
set @sql=N'select @a ='+' name from sysobjects where id = 2007678200'
EXECUTE sp_executesql @sql , N'@a varchar(20) OUTPUT' , @a = @a OUTPUT
PRINT @a
/*结果
sp_DTA_wkld_analysis
*/
declare @a varchar(20),@sql Nvarchar(200)
set @sql=N'select @a =Phone from House where Phone=''13902273189'''
exec sp_executesql @sql,N'@a varchar(30) output ',@a output
select @a