-
How to find a specific value that exists in one of the 3 tables
I am trying to find a certain value that exists in 3 tables with identical columns and I am trying to find with this process
DECLARE @SearchValue NVARCHAR(255)
SET @SearchValue = 'YourSearchValue'
-- Search in Table1
SELECT 'Table1' AS TableName, YourColumnName AS MatchedValue
FROM Table1
WHERE YourColumnName = @SearchValue
-- Search in Table2
UNION ALL
SELECT 'Table2' AS TableName, YourColumnName AS MatchedValue
FROM Table2
WHERE YourColumnName = @SearchValue
-- Search in Table3
UNION ALL
SELECT 'Table3' AS TableName, YourColumnName AS MatchedValue
FROM Table3
WHERE YourColumnName = @SearchValue
The problem is that in the search every time I get an error about the highlighted field even when I change the field type
for example the value housenum=273 in the three tables house1,house2,house3
if you have another way its ok
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|