SQL 조회,지정 필드 제외

http://blog.163.com/tianshenglongchang@126/blog/static/164628503201231925214824/
             
declare @name varchar(100) declare @sql varchar(1000)   SET @sql='select ' DECLARE C11 CURSOR FOR  select name from syscolumns where id= (select max(id) from sysobjects where xtype='u' and name='  ') and name <> '     ' OPEN C11  FETCH NEXT FROM C11 INTO              @name IF @@FETCH_STATUS <> 0  BEGIN      DEALLOCATE C11      RETURN END  WHILE(@@FETCH_STATUS = 0) BEGIN      SET @sql=@sql+@name+','       FETCH NEXT FROM C11 INTO       @name END DEALLOCATE C11  set @sql=substring(@sql,1,len(@sql)-1)+' from   '  exec (@sql)

--어떤 표 의 모든 필드 조회
select name from syscolumns where id=(select max(id)from sysobjects where xtype='u'and name='표 이름')
다음으로 전송:https://www.cnblogs.com/sulong/p/4800795.html

좋은 웹페이지 즐겨찾기