当前位置: 代码迷 >> SQL >> 惯用sql查询语句
  详细解决方案

惯用sql查询语句

热度:84   发布时间:2016-05-05 14:54:21.0
常用sql查询语句
查询数据库所有表
select table_name from information_schema.tables 


查询数据库所有字段
select table_name from information_schema.columns 



查询数据库所有视图
select table_name from information_schema.views




查询数据库所有表数据
DECLARE TableCursor SCROLL CURSOR FOR	select table_name from information_schema.columns order by table_nameOPEN TableCursor		DECLARE @TmpTableName Nvarchar(100);		WHILE 1 = 1BEGIN	FETCH NEXT FROM TableCursor INTO @TmpTableName	If @@FETCH_STATUS != 0				BEGIN					break				End			ELSE				--print @TmpTableName 				BEGIN TRY					exec('select * from ' + @TmpTableName );				END TRY				BEGIN CATCH					exec('select * from ' + @TmpTableName);				END CATCH		END		CLOSE TableCursor		DEALLOCATE TableCursor
  相关解决方案