日期:2014-05-18  浏览次数:20508 次

sql output
use message
declare @cmd as nvarchar(200)
declare @name as nvarchar(200)
declare @exchange as nvarchar(200)
set @cmd='select username from systemuser where useraccounts=''ABC'''
select @cmd as '@cmd'
exec sp_executesql @cmd,N'@exchange nvarchar(200) output',@exchange output
select @exchange as 'Condition'



------解决方案--------------------
SQL code

declare @cmd  nvarchar(8000) 
declare @exchange  nvarchar(200) 
set @cmd= 'select @username=username from systemuser where useraccounts= ''ABC ''' 
exec sp_executesql @cmd,N '@username nvarchar(200) output ',@exchange output