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.
declare @test varchar(8000)
declare @Db varchar(8000)
declare @flFirst bit
DECLARE Test CURSOR READ_ONLY FAST_FORWARD FOR
SELECT Catalog_name from INFORMATION_SCHEMA.SCHEMATA
SET @Test = ''
SET @flFirst = 1
OPEN Test
FETCH NEXT FROM Test INTO @db
WHILE @@FETCH_STATUS = 0
BEGIN
IF OBJECT_ID(@db+'.dbo.TableX') IS NOT NULL
BEGIN
IF @flFirst = 0
SET @Test = @Test + ' UNION ALL '
SET @Test = @Test + ' SELECT * FROM '+@db+'.dbo.TableX'
SET @flFirst = 0
END
FETCH NEXT FROM Test INTO @db
END
PRINT @test
CLOSE Test
DEALLOCATE Test
EXEC(@test)
SELECT * FROM DB1.dbo.TableX
UNION ALL
SELECT * FROM DB2.dbo.TableX
UNION ALL
SELECT * FROM DB3.dbo.TableX
....
UNION ALL
SELECT * FROM DB25.dbo.TableX