InfoSys SQL

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

你可能感兴趣的:(info)