大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
-----------------------------------------------------------------------------------------------------------------------------------------------------
use DSCSYS
go
DECLARE
@TableName nvarchar(100) = 'COPTD'
,@DataBase nvarchar(100) = 'TOPLED2015'
,@SQL nvarchar(4000)
,@Where nvarchar(4000) = ' where '
set @SQL = 'select MD001,MD003,MD004,MD005,MD006,MD007 from DSCSYS..ADMMD where MD001 = '+ '''' +
@TableName + ''' and substring(MD003,1,2) = substring(''' + @TableName + ''',4,2)'
exec(@SQL)
----------------------------------------------------------------------------------------------------------------------------------------------------
set @SQL =
STUFF((SELECT ','+ rtrim(MD003) + ' as ''' + rtrim(MD004) + ''''
FROM ADMMD
where MD001 = @TableName and substring(MD003,1,2) = substring(@TableName,4,2)
FOR xml path('')),1,1,'')
set @SQL =replace('select * from ','*',@SQL) + @DataBase + '..' + @TableName
exec(@SQL)
-------------------------------------------------------------------------------------------------------------------------------------------------------
select MD001,MD003,MD004,MD005,MD006,MD007,* from DSCSYS..ADMMD
where MD001 = 'PURTC' and MD003 = 'UDF12'
update DSCSYS..ADMMD set UDF01 = '质保年限'
where MD001 = 'PURTC' and MD003 = 'UDF12'