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 2005 Forums
 Transact-SQL (2005)
 innner join system object

Author  Topic 

ilimax
Posting Yak Master

164 Posts

Posted - 2010-09-14 : 10:17:10
I have some tables that are created on fly by ID column from Table1.

Table2_100
Table2_101
Table2_102

I want to pull IDs from Table1 that object Table2_ID does not exist.

Anybody have idea how I can make this?

CSears
Starting Member

39 Posts

Posted - 2010-09-14 : 10:33:44
Without a better explanation I would say possibly using a

WHERE Table1_ID NOT IN (SELECT Table2_ID FROM Table2)

clause.
Go to Top of Page

ilimax
Posting Yak Master

164 Posts

Posted - 2010-09-14 : 16:01:41
Definatelly that is not what I asked for ...
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-09-14 : 16:51:15
[code]select ID
from table1
where not exists(select * from sys.objects
where name = 'Table2_'+convert(varchar(10),table1.ID)
and type='U')
[/code]


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

ilimax
Posting Yak Master

164 Posts

Posted - 2010-09-14 : 17:14:54
That one is great .. works great .. Thank you very much.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-09-14 : 17:16:07
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -