Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Returning table names in Select queries

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-02-24 : 21:04:23
Charles writes "I wrote this query to select certain data from multiple tables, the result set doesnt show which table the rows are selected from. Usually when I run this script I'm more intrested in the tables rather than the data itself. Is there a way to do this?
Here's my query:
SELECT * FROM table1 WHERE column1 LIKE '%xxx%'
SELECT * FROM table2 WHERE column1 LIKE '%xxx%'
SELECT * FROM table3 WHERE column1 LIKE '%xxx%'
This can reach up to 70 different tables in our database. Thanks in advance.

Sql Server 7.0 and 2000, Windows 2000 "

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2002-02-24 : 21:04:23
How about:

SELECT TableName = 'table1', *
FROM table1
WHERE column1 LIKE '%xxx%'
Go to Top of Page
   

- Advertisement -