SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Better approach for this query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

offlyn
Starting Member

1 Posts

Posted - 08/13/2008 :  15:39:59  Show Profile  Reply with Quote
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

United Kingdom
122 Posts

Posted - 08/14/2008 :  04:41:11  Show Profile  Reply with Quote
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

India
52323 Posts

Posted - 08/14/2008 :  14:40:05  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000