create table #temp(Name varchar(50))--创建临时表  
insert #temp
select name from syscolumns where id=(select max(id) from sysobjects where xtype='u' and name='T_Staff')
select * from #temp
 declare @MyCursor CURSOR
 declare @Name nvarchar(50)
 set @MyCursor= CURSOR LOCAL SCROLL FOR   
               select [name] from #temp  where [Name]<>'Name'
               OPEN @MyCursor
               fetch next from @MyCursor into @Name
           while @@fetch_status=0
               begin  
   select cast(dbo.converttrim(@Name) as numeric(9,0)) as ColumnName from  dbo.T_Staff
          if(@@ERROR>0)
   begin
                   print @Name
    continue
   end
    fetch next from @MyCursor into @Name      
               end
            close @MyCursor
             deallocate @MyCursor
drop table #temp

相关文章:

  • 2021-12-12
  • 2021-08-07
  • 2021-06-18
  • 2021-07-26
  • 2021-07-12
  • 2021-11-24
  • 2021-10-25
  • 2021-12-31
猜你喜欢
  • 2022-12-23
  • 2021-07-07
  • 2022-01-21
  • 2022-12-23
  • 2021-06-21
  • 2021-09-19
  • 2021-10-22
相关资源
相似解决方案