Lunar Whisper
Lunar Whisper

Reputation: 210

How to union many tables with same name but different schema without dynamic sql?

Microsoft SQL Server

I want to union them. For example:

select * from [*].[MyTable]

Can I do that?

Upvotes: 0

Views: 182

Answers (1)

Pரதீப்
Pரதீப்

Reputation: 93704

Something like this

select * from [dbo].[MyTable]
UNION
select * from [schema1].[MyTable]
UNION
select * from [schema2].[MyTable]
UNION
select * from [schema3].[MyTable]

Upvotes: 1

Related Questions