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
 General SQL Server Forums
 Database Design and Application Architecture
 Query Rewrite... please.

Author  Topic 

abcefg
Starting Member

16 Posts

Posted - 2009-03-16 : 02:30:12
How tp rewrite this query. for improvement....


Inser into DIMDisBand
SELECT
distinct
''as[DIMDisBendNativeId]
,BDHW.dbo.DIMDis.DIMDisId AS fk_DIMDisId
,BLIVE.dbo.DisBand.LLimit
,BLIVE.dbo.DisBand.ULimit
,BLIVE.dbo.DisCode.CName
,BLIVE.dbo.DisBand.PDisValue
,BLIVE.dbo.DisBand.ValueDisVal
,BLIVE.dbo.DisBand.Updated_On AS LastModified
,1 AS fkdimcountryid
FROM BLIVE.dbo.DisBand INNER JOIN
BLIVE.dbo.DisCode ON BLIVE.dbo.DisBand.fkDiscountId = BLIVE.dbo.DisCode.DiscountId INNER JOIN
BDHW.dbo.DIMDis ON BLIVE.dbo.DisCode.DiscountId = BDHW.dbo.DIMDis.DIMDisNativeId
where BDHW.dbo.DIMDis.DIMDisId in (select fk_DIMDisId from BDHW.dbo.DIMDisBand)
and
cast(BDHW.dbo.DIMDis.DIMDisId as varchar(50))
+ cast(BLIVE.dbo.DisBand.LLimit as varchar(50))
+ cast(BLIVE.dbo.DisBand.ULimit as varchar(50))
+ cast(BLIVE.dbo.DisCode.CName as varchar(50))
+ cast (BLIVE.dbo.DisBand.PDisValue as varchar(50))
+ cast (BLIVE.dbo.DisBand.ValueDisVal as varchar(50))
not in
(select
cast(fk_DIMDisId as varchar(50))
+ cast(LLimit as varchar(50))
+ cast(ULimit as varchar(50))
+ cast(BandName as varchar(50))
+ cast (PDisValue as varchar(50))
+ cast (ValueDisVal as varchar(50))
from BDHW.dbo.DIMDisBand )

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-16 : 03:07:35
Duplicate post http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=121600



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -