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.
Author |
Topic |
tariq2
Posting Yak Master
125 Posts |
Posted - 2012-02-13 : 11:58:50
|
Hi, was just wondering eny the below doesnt quite work?Something to do with the insertion? select * into #temptablefrom (select b.JobID,a.* from F_Audit a inner join D_JobAttributes b on a.JobKey = b.JobKey where a.JobKey in (select jobkey from D_JobAttributes where JobID in ('080023200108','080023200110','080023200111','080023200112','080023200113','080280580202','080280580203','080280720101','080280720102','080280720103','080281510109','090290130103','090291280103','090291280104','0903141801','0903284002','090340000105','090344360520','090354290107','090355700166','090355700265','100000010105','100035380102','100035380104','100105960103','100173500101','100176090102','100188440104','100193220102','100329640103','100343160102','100343160103','100418120103','100448190102','100448190103','100453810103','100502830102','100502830103','100502830104','100519490102','100519490103'))) |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-02-13 : 12:07:22
|
quote: Originally posted by tariq2 Hi, was just wondering eny the below doesnt quite work?Something to do with the insertion? select * into #temptablefrom (select b.JobID,a.* from F_Audit a inner join D_JobAttributes b on a.JobKey = b.JobKey where a.JobKey in (select jobkey from D_JobAttributes where JobID in ('080023200108','080023200110','080023200111','080023200112','080023200113','080280580202','080280580203','080280720101','080280720102','080280720103','080281510109','090290130103','090291280103','090291280104','0903141801','0903284002','090340000105','090344360520','090354290107','090355700166','090355700265','100000010105','100035380102','100035380104','100105960103','100173500101','100176090102','100188440104','100193220102','100329640103','100343160102','100343160103','100418120103','100448190102','100448190103','100453810103','100502830102','100502830103','100502830104','100519490102','100519490103')))t
you're missing an alias------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
X002548
Not Just a Number
15586 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-02-13 : 12:09:59
|
If its one time query its fineotherwise it would probably be better to put the ids along with job keys onto a temporary table and then use exists to check if jobid is one among the ids in temporary table. you can also add an index on temporary table to speed up search based on jobid especially if number of ids involved is large------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
X002548
Not Just a Number
15586 Posts |
|
X002548
Not Just a Number
15586 Posts |
|
tariq2
Posting Yak Master
125 Posts |
Posted - 2012-02-13 : 12:20:05
|
thank you guys, very helpful :) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-02-13 : 12:25:36
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|
|
|