日期:2014-05-17 浏览次数:20497 次
declare @num_1 table ([num] int)
declare @num int
insert @num_1 Exec(@sql)
select @num=[num] from @num_1
DROP TABLE dbo.tab
go
CREATE TABLE [dbo].[tab]
(
[id] [int] NOT NULL IDENTITY(1, 1),
[title] [nvarchar] (50),
[name] [nvarchar] (20),
[time] [datetime]
)
GO
INSERT tab(name) VALUES('test')
go
ALTER proc sp_ksxs1
@JGBZ NVARCHAR(50),
@column1 nVARCHAR(50)
as
declare @num numeric(3,2),@sql nvarchar(500)
IF object_id('tempdb..#temp', 'u') IS NOT NULL
DROP TABLE #temp
CREATE TABLE #temp(COLUMN1 VARCHAR(10))
set @sql = 'select '+ QUOTENAME(@column1) +' from tab where name='''+ @JGBZ +''''
INSERT #temp(COLUMN1)
Exec(@sql)
select TOP(1) @num = COLUMN1 FROM #temp
DROP TABLE #temp