日期:2014-05-18 浏览次数:20544 次
create table totalday (swsb varchar(50), swxb varchar(50), xwsb varchar(50), xwxb varchar(50), wssb varchar(50), wsxb varchar(50), kqkh varchar(50), rq varchar(50)) insert totalday select '1', '2', '3', '4', '5', '6', '001', '2007-10-20' GO create Procedure Sp_Uptotalday @sssj varchar(8), @time varchar(50) output, @rq varchar(10), @kqkh varchar(10) AS Begin Declare @sql nvarchar(100) declare @oldtime varchar(50) set @sql = 'SELECT @oldtime = ' + @sssj + ' from totalday where rq = ''' + @rq + ''' and kqkh=''' + @kqkh + '''' exec sp_executesql @sql, N'@oldtime varchar(50) OUTPUT', @oldtime OUTPUT set @time = @oldtime END GO declare @time varchar(50) exec Sp_Uptotalday 'swsb', @time OUTPUT, '2007-10-20', '001' select @time GO drop table totalday drop procedure Sp_Uptotalday