CREATE PROCEDURE [dbo].[获取设备参数值]
@tableName nvarchar(100),
@id nvarchar(500)
AS
declare @s varchar(1000)
set @s = ''
select @s=@s+''''+rtrim(name) + ''',' from syscolumns where id = object_id(@tableName) and name not in
('备用代码','备注','批准是否通过')
order by colidset @s=left(@s,len(@s)-1)exec('select ' + @s + ' from ' + @tableName + ' where equipID in (' + @id + ')')
@tableName nvarchar(100),
@id nvarchar(500)
AS
declare @s varchar(1000)
set @s = ''
select @s=@s+''''+rtrim(name) + ''',' from syscolumns where id = object_id(@tableName) and name not in
('备用代码','备注','批准是否通过')
order by colidset @s=left(@s,len(@s)-1)exec('select ' + @s + ' from ' + @tableName + ' where equipID in (' + @id + ')')
@tableName nvarchar(100),
@id nvarchar(500)
AS
declare @s varchar(1000)
set @s = ''
select @s=@s+'a.'+rtrim(name) + ',' from syscolumns where id = object_id(@tableName) and name not in
('备用代码','备注','批准是否通过')
order by colid
set @s=left(@s,len(@s)-1)
exec('select ' + @s + ',b.[5个字段] from ' + @tableName + ' a,另一个表 b where equipID in (' + @id + ') and a.equip=b.equip')