Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
USE YourDatabase
CREATE TABLE #Tmp (sql varchar(max))
EXEC sp_MSforeachtable '
DECLARE @sql varchar(max)
SET @sql = ''SELECT ''''?'''' AS TableName ''
SELECT @sql = @sql + CASE WHEN Data_Type IN (''bit'',''text'') THEN '''' ELSE '', MAX(''+Column_Name+'') AS ''+Column_Name END
FROM Information_Schema.Columns
WHERE QUOTENAME(Table_Name) = SUBSTRING(''?'',CHARINDEX(''['',''?'',3),8000)
SET @sql = @sql+'' FROM ?''
INSERT INTO #Tmp VALUES (@sql)
'
DECLARE @sql nvarchar(max)
SET @sql = ''
SELECT @sql = @sql + Sql+CHAR(13)+CHAR(10) FROM #Tmp
DROP TABLE #Tmp
EXEC sp_executesql @sql
I have a small database with 10-12 tables.
I wrote a script using cursor but it takes a long time since i have close to 3000 tables.