Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a single server consisting of many database.

There is a common view(v_xyz) which exists in all the database. This view consists of multiple columns.(column A, Column
B,.....)

Column A consists of Product Ids and Column B consists of Path where these Product Ids can be found.

I need to check in all the database whether any Product Ids exists in 2 different paths across the database.

Path could consists of words like '%pqr%' or '%abc%'

What I have tried:

So I tried using the like clause but i have to change the database every now and then.

Please help.
Posted
Updated 8-Apr-19 21:04pm

1 solution

You can create view something like this

SQL
CREATE VIEW ViewName
AS

SELECT ColumnName FROM [Database1].[Database].dbo.TableName
UNION ALL
SELECT ColumnName [Database2].dbo.TableName
UNION ALL
SELECT ColumnName FROM [Database3].dbo.TableName


After that you can do your logic according to your need.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900