DECLARE @TABLE_NAME VARCHAR(200) SET @TABLE_NAME = ‘myFunction‘ --表名 DECLARE @TABLE_CONDITION VARCHAR(200) SET @TABLE_CONDITION = ‘where Application=‘‘0303‘‘ AND FunctionType=‘‘功能‘‘‘ --条件 DECLARE @sql VARCHAR(5000) SET @sql=‘‘ DECLARE @col VARCHAR(5000) SET @col=‘‘ DECLARE @scol VARCHAR(5000) SET @scol=‘‘ SELECT @[email protected]+‘,‘+NAME ,@[email protected]+‘,‘‘‘‘‘‘+ISNULL(convert(varchar(5000),‘+NAME+‘),‘‘‘‘)+‘‘‘‘‘‘‘ from syscolumns Where ID=OBJECT_ID(@TABLE_NAME) SET @col=RIGHT(@col,LEN(@col)-1) SET @scol=substring(@scol,2,LEN(@scol)-1)+‘‘‘‘ --SELECT @col,@scol set @sql = ‘SELECT ‘‘ insert into ‘+ @TABLE_NAME +‘(‘[email protected]+‘) values (‘ + @scol +‘ +‘‘)‘‘ from ‘[email protected]_NAME+‘ ‘ + @TABLE_CONDITION EXEC (@sql)
时间: 2024-10-30 16:34:50