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)
 Better approach for this query

Author  Topic 

offlyn
Starting Member

1 Post

Posted - 2008-08-13 : 15:39:59
The follwoing sql works but I am looking for a better approach for doing this without using:
from tbl1 a
join tbl2 b
on a.id = a.id

INSERT INTO tbl3
a.[id],
b.[id]
[CreatedBy],
[CreatedDate]
select distinct
a.id,
b.id,
1234,
getdate
from tbl1 a
join tbl2 b
on a.id = a.id
where b.ID IN 1,2,3
and a.emailaddress in
select distinct emailname from bulkuserupload

The dataset would be:
id1 id2 createdby createddate
1 1 1234 12/1/2005
1 2 1234 12/1/2005
1 3 1234 12/1/2005
1 1 1234 12/1/2005
1 2 1234 12/1/2005
1 3 1234 12/1/2005


Thanks in advance for you input.

georgev
Posting Yak Master

122 Posts

Posted - 2008-08-14 : 04:41:11
Can you copy-paste the actual code you're using... The above will produce syntax errors.

Oh and while you're doing that, read this: http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx


George
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-14 : 14:40:05
Not sure what you're trying to do the join condition is wrong a.id = a.id. please post correct query or provide some sample data & explain.
Go to Top of Page
   

- Advertisement -