Thursday, 4 July 2013

select all columns from all tables

DECLARE @SQL AS VarChar(MAX)
SET @SQL = ''
SELECT @SQL = @SQL + 'SELECT * FROM ' + TABLE_SCHEMA + '.' + TABLE_NAME + CHAR(13)
FROM INFORMATION_SCHEMA.TABLES
EXEC (@SQL)


OR

sp_msforeachtable 'select  * from ?'

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...