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
 New to SQL Server Programming
 Query taking time

Author  Topic 

praveen.paspulate
Starting Member

14 Posts

Posted - 2011-05-03 : 10:47:22
Hello,

The below query retrieve 20+ million rows. It takes around 3 hours.

Can anyone please advise the best query to display fast.

SELECT DISTINCT
TOP 100 PERCENT dbo.Filings.FilingID, dbo.zStates.StName, dbo.Filings.Title,
#tmpEmployees.LName, #tmpEmployees.FName, #tmpEmployees.UserID,
dbo.StatDate.MailDate, dbo.StatDate.AppDate, dbo.zProgs.Title, dbo.zFlngSts.Status,
dbo.zStates.Int_STID, dbo.zRequest.RequstBy, dbo.Filings.BrthDate, dbo.Filings.ReqDate, dbo.StatDate.ReqDate,
dbo.Filings.Int_FLID, dbo.StatDate.EffDate, dbo.StatDate.REffDate,
#tmpIdentity.LOB, #tmpIdentity.Type,#tmpIdentity.LBPR
FROM #tmpIdentity RIGHT OUTER JOIN
dbo.Filings ON #tmpIdentity.FLID = dbo.Filings.Int_FLID LEFT OUTER JOIN
#tmpEmployees RIGHT OUTER JOIN
dbo.zFlngSts INNER JOIN
dbo.StatDate ON dbo.zFlngSts.Int_FSID = dbo.StatDate.Int_FSID ON #tmpEmployees.STID = dbo.StatDate.Int_STID AND
#tmpEmployees.FLID = dbo.StatDate.Int_FLID LEFT OUTER JOIN
dbo.zStates ON dbo.StatDate.Int_STID = dbo.zStates.Int_STID ON dbo.Filings.Int_FLID = dbo.StatDate.Int_FLID LEFT OUTER JOIN
dbo.FilProgFnl INNER JOIN
dbo.zProgs ON dbo.FilProgFnl.Int_PRID = dbo.zProgs.Int_PRID ON dbo.Filings.Int_FLID = dbo.FilProgFnl.Int_FLID LEFT OUTER JOIN
dbo.zRequest ON dbo.Filings.Int_RBID = dbo.zRequest.Int_RBID

chris_cs
Posting Yak Master

223 Posts

Posted - 2011-05-03 : 10:49:40
Have you looked at the execution plan?
Go to Top of Page

praveen.paspulate
Starting Member

14 Posts

Posted - 2011-05-03 : 10:58:58
Hello,

It is a DTS package. In this package a Execute SQL task takes above 3 hours. It consist the above query it retrieve around 20+ million rows.
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2011-05-03 : 11:18:44
quote:
Originally posted by praveen.paspulate

Hello,

It is a DTS package. In this package a Execute SQL task takes above 3 hours. It consist the above query it retrieve around 20+ million rows.



It is a query run in a DTS package, So....

quote:

Have you looked at the execution plan?



And I'll add: where's the rest? You reference some temp tables, but I don't see them defined...

Corey

I Has Returned!!
Go to Top of Page

chris_cs
Posting Yak Master

223 Posts

Posted - 2011-05-03 : 13:04:45
The first thing you need to do is look at the execution plan for the query, regardless of whether or not the query is part of a DTS package.

This will give you some clues as to why the query is taking so long. There is plenty of information on this in BOL that will help you.
Go to Top of Page

praveen.paspulate
Starting Member

14 Posts

Posted - 2011-05-03 : 13:13:56
CREATE PROCEDURE dbo.View_Filing_Master AS

create table #tmpFilings(FilingID varchar(50), States varchar(150), Title char(2000), EmpLName varchar(50), EmpFName varchar(50), EmpUserID char(25),
MailDate datetime, AppDate datetime, Program varchar(255), Status varchar(255), STID smallint,
RequestBy varchar(255), BrthDate datetime, FilingReqDate datetime, StatReqDate datetime, FLID char(12), EffDate datetime, REffDate datetime,
LOBs varchar(150), Type char(10),Int_LBID varchar(12))

create table #tmpEmployees (UserID varchar(25), FNAME varchar(50), LNAME varchar(50), EMID char(12), FLID char(12), STID char(12))

create table #tmpFilingFrmLOBs (LOB char(150), FLID char(12),Int_LBID varchar(12),Int_STID varchar(5))
create table #tmpFilingRatLOBs (LOB char(150), FLID char(12),Int_LBID varchar(12),Int_STID varchar(5))
create table #tmpFilingRulLOBs (LOB char(150), FLID char(12),Int_LBID varchar(12),Int_STID varchar(5))

create table #tmpIdentity (LBPR char(12), Title varchar(255), LOB varchar(50), FLID char(12), Type char(10),Int_STID varchar(5))
create table #tmpIdentityForms (LBPR char(12), Title varchar(255), LOB varchar(50), FLID char(12), Type char(10),Int_STID varchar(5))
create table #tmpIdentityRates (LBPR char(12), Title varchar(255), LOB varchar(50), FLID char(12) ,Type char(10),Int_STID varchar(5))
create table #tmpIdentityRules (LBPR char(12), Title varchar(255), LOB varchar(50), FLID char(12), Type char(10),Int_STID varchar(5))

create table #tmpFilingFrm(FilingID varchar(50), StName varchar(150), Title varchar(2000), LastName varchar(50), FirstName varchar(50),
UserID char(25), ReqDate datetime, MailDate datetime, AppDate datetime, Status varchar(255), Program varchar(255),
ReqBy varchar(255), EffDate datetime, REffDate datetime, BrthDate datetime, FLID char(12), LOB varchar(150), STID smallint, Type char(10),Int_LBID varchar(12))
create table #tmpFilingRat(FilingID varchar(50), StName varchar(150), Title varchar(2000), LastName varchar(50), FirstName varchar(50),
UserID char(25), ReqDate datetime, MailDate datetime, AppDate datetime, Status varchar(255), Program varchar(255),
ReqBy varchar(255), EffDate datetime, REffDate datetime, BrthDate datetime, FLID char(12), LOB varchar(150), STID smallint, Type char(10) ,Int_LBID varchar(12))
create table #tmpFilingRul(FilingID varchar(50), StName varchar(150), Title varchar(2000), LastName varchar(50), FirstName varchar(50),
UserID char(25), ReqDate datetime, MailDate datetime, AppDate datetime, Status varchar(255), Program varchar(255),
ReqBy varchar(255), EffDate datetime, REffDate datetime, BrthDate datetime, FLID char(12), LOB varchar(150), STID smallint, Type char(10),Int_LBID varchar(12) )

DECLARE @sqlEmployees varchar(3000)
DECLARE @sqlFilingFrmLOBs varchar(3000)
DECLARE @sqlFilings varchar(5000)
DECLARE @sqlFilingFrm varchar(5000)
DECLARE @sqlFilingRatLOBs varchar(3000)
DECLARE @sqlFilingRat varchar(5000)
DECLARE @sqlFilingRulLOBs varchar(3000)
DECLARE @sqlFilingRul varchar(5000)
DECLARE @sqlidentityForms varchar(3000)
DECLARE @sqlidentityRates varchar(3000)
DECLARE @sqlidentityRules varchar(3000)
DECLARE @sqlidentity varchar(5000)
DECLARE @sqlFilProg varchar(5000)

Set @sqlEmployees = 'SELECT DISTINCT
dbo.zEmploys.UserID, dbo.zEmploys.FName, dbo.zEmploys.LName, dbo.zEmploys.Int_EMID, dbo.FCYSTFrmEmpl.Int_FLID,
dbo.FCYSTFrmEmpl.Int_STID
FROM dbo.zEmploys INNER JOIN
dbo.FCYSTFrmEmpl ON dbo.zEmploys.Int_EMID = dbo.FCYSTFrmEmpl.Int_EMID'
insert into #tmpEmployees
EXEC (@sqlEmployees)

SET @sqlFilingFrmLOBs = 'SELECT DISTINCT dbo.zLOBs.LOB, dbo.Filings.Int_FLID,zLOBs.Int_LBID,FCYSTFRM.INT_STID
FROM dbo.Filings INNER JOIN
dbo.FCYSTFrm ON dbo.Filings.Int_FLID = dbo.FCYSTFrm.Int_FLID INNER JOIN
dbo.LOBPRFrm ON dbo.FCYSTFrm.Int_FMID = dbo.LOBPRFrm.Int_FMID INNER JOIN
dbo.zLOBs ON dbo.LOBPRFrm.Int_LBPR = dbo.zLOBs.Int_LBID'
insert into #tmpFilingFrmLOBs
EXECUTE ( @sqlFilingFrmLOBs)

SET @sqlFilingRatLOBs = 'SELECT DISTINCT dbo.zLOBs.LOB, dbo.Filings.Int_FLID,zLOBS.Int_LBID,FCYSTRAT.INT_STID
FROM dbo.Filings INNER JOIN
dbo.FCYSTRat ON dbo.Filings.Int_FLID = dbo.FCYSTRat.Int_FLID INNER JOIN
dbo.LOBPRRat ON dbo.FCYSTRat.Int_RTID = dbo.LOBPRRat.Int_RTID INNER JOIN
dbo.zLOBs ON dbo.LOBPRRat.Int_LBPR = dbo.zLOBs.Int_LBID'
insert into #tmpFilingRatLOBs
EXECUTE ( @sqlFilingRatLOBs)
SET @sqlFilingRulLOBs = 'SELECT DISTINCT dbo.zLOBs.LOB, dbo.Filings.Int_FLID,zLOBS.Int_LBID,FCYSTRUL.INT_STID
FROM dbo.Filings INNER JOIN
dbo.FCYSTRul ON dbo.Filings.Int_FLID = dbo.FCYSTRul.Int_FLID INNER JOIN
dbo.LOBPRRul ON dbo.FCYSTRul.Int_RLID = dbo.LOBPRRul.Int_RLID INNER JOIN
dbo.zLOBs ON dbo.LOBPRRul.Int_LBPR = dbo.zLOBs.Int_LBID'
insert into #tmpFilingRulLOBs
EXECUTE ( @sqlFilingRulLOBs)

-- new 12-19-2005

Set @sqlidentityForms = 'SELECT DISTINCT LOBPRFrm.Int_LBPR, zProgs.Title, zLOBs.LOB, FCYSTFrm.Int_FLID, ''Form'' AS Type,FCYSTFRM.INT_STID
FROM FCYSTFrm INNER JOIN
LOBPRFrm ON FCYSTFrm.Int_FMID = LOBPRFrm.Int_FMID LEFT OUTER JOIN
zProgs ON LOBPRFrm.Int_LBPR = zProgs.Int_PRID LEFT OUTER JOIN
zLOBs ON LOBPRFrm.Int_LBPR = zLOBs.Int_LBID'
insert into #tmpIdentityForms
EXEC (@sqlidentityForms)

Set @sqlidentityRates = 'SELECT DISTINCT LOBPRRat.Int_LBPR, zProgs.Title, zLOBs.LOB, FCYSTRat.Int_FLID, ''Rate''AS Type,FCYSTRAT.INT_STID
FROM FCYSTRat INNER JOIN
LOBPRRat ON FCYSTRat.Int_RTID = LOBPRRat.Int_RTID LEFT OUTER JOIN
zProgs ON LOBPRRat.Int_LBPR = zProgs.Int_PRID LEFT OUTER JOIN
zLOBs ON LOBPRRat.Int_LBPR = zLOBs.Int_LBID'
insert into #tmpIdentityRates
EXEC (@sqlidentityRates)

Set @sqlidentityRules = 'SELECT DISTINCT LOBPRRul.Int_LBPR, zLOBs.LOB, zprogs.title, FCYSTRul.Int_FLID, ''Rule'' AS Type,FCYSTRUL.INT_STID
FROM FCYSTRul INNER JOIN
LOBPRRul ON FCYSTRul.Int_RLID = LOBPRRul.Int_RLID LEFT OUTER JOIN
zProgs ON LOBPRRul.Int_LBPR = zProgs.Int_PRID LEFT OUTER JOIN
zLOBs ON LOBPRRul.Int_LBPR = zLOBs.Int_LBID'
insert into #tmpIdentityRules
EXEC (@sqlidentityRules)

Set @sqlIdentity = 'SELECT DISTINCT #tmpIdentityRules.LBPR, #tmpIdentityRules.Title, #tmpIdentityRules.LOB, #tmpIdentityRules.FLID, ''Rule'' AS Type,INT_STID
FROM #tmpIdentityRules
UNION
SELECT DISTINCT #tmpIdentityRates.LBPR, #tmpIdentityRates.Title, #tmpIdentityRates.LOB, #tmpIdentityRates.FLID, ''Rate'' AS Type,INT_STID
FROM #tmpIdentityRates
UNION
SELECT DISTINCT #tmpIdentityForms.LBPR, #tmpIdentityForms.Title, #tmpIdentityForms.LOB, #tmpIdentityForms.FLID, ''Form'' AS Type ,INT_STID
FROM #tmpIdentityForms'
insert into #tmpIdentity
EXEC (@sqlidentity)

--> Changes to handle the Filings progs assciation. 15 May 2007
Truncate Table FilProgFnl

set @sqlFilProg = 'select distinct fcystrul.int_flid, LOBPRRul.int_LBPR from fcystrul
Inner Join LOBPRRul ON FCYSTRul.Int_RLID = LOBPRRul.Int_RLID inner join zProgs on LOBPRRul.int_LBPR = zProgs.Int_PRID
where LOBPRrul.int_LBPR like ''PR%''
AND fcystrul.int_flid+LOBPRRul.int_LBPR Not in (select distinct int_flid+Int_PRID from filprogfnl)
And zProgs.Deleted Like ''N'''

Insert into FilProgFnl
Exec (@sqlFilProg)

SEt @sqlFilProg='select distinct fcystrat.int_flid, LOBPRRat.int_LBPR from fcystrat
Inner Join LOBPRRat ON FCYSTRat.Int_RTID = LOBPRRat.Int_RTID inner join zProgs on LOBPRRat.int_LBPR = zProgs.Int_PRID
where LOBPRRat.int_LBPR like ''PR%''
AND fcystrat.int_flid+LOBPRRat.int_LBPR Not in (select distinct int_flid+Int_PRID from filprogfnl)
And zProgs.Deleted Like ''N'''
Insert into FilProgFnl
Exec (@sqlFilProg)

Set @sqlFilProg='select distinct fcystfrm.int_flid, LOBPRFrm.int_LBPR from fcystfrm
Inner Join LOBPRFrm ON FCYSTFRM.Int_FMID = LOBPRFrm.Int_FMID inner join zProgs on LOBPRFrm.int_LBPR = zProgs.Int_PRID
where LOBPRFrm.int_LBPR like ''PR%''
AND fcystfrm.int_flid+LOBPRfrm.int_LBPR Not in (select distinct int_flid+Int_PRID from filprogfnl)
And zProgs.Deleted Like ''N'''
insert into fIlprogFnl
Exec (@sqlFilProg)

-- Set @sqlFilProg = 'Select FilProg.int_flid, filprog.int_Prid from Filprog Inner join zProgs on FilProg.int_PRID = zProgs.int_Prid where zProgs.Deleted like ''N'''
-- Insert into FilProgFnl
-- Exec (@sqlFilProg)

-->Changed to handle Filing Progs Association


--The below query Returning 20+ million rows

Set @sqlFilings = 'SELECT DISTINCT
TOP 100 PERCENT dbo.Filings.FilingID, dbo.zStates.StName, dbo.Filings.Title,
#tmpEmployees.LName, #tmpEmployees.FName, #tmpEmployees.UserID,
dbo.StatDate.MailDate, dbo.StatDate.AppDate, dbo.zProgs.Title, dbo.zFlngSts.Status,
dbo.zStates.Int_STID, dbo.zRequest.RequstBy, dbo.Filings.BrthDate, dbo.Filings.ReqDate, dbo.StatDate.ReqDate,
dbo.Filings.Int_FLID, dbo.StatDate.EffDate, dbo.StatDate.REffDate,
#tmpIdentity.LOB, #tmpIdentity.Type,#tmpIdentity.LBPR
FROM #tmpIdentity RIGHT OUTER JOIN
dbo.Filings ON #tmpIdentity.FLID = dbo.Filings.Int_FLID LEFT OUTER JOIN
#tmpEmployees RIGHT OUTER JOIN
dbo.zFlngSts INNER JOIN
dbo.StatDate ON dbo.zFlngSts.Int_FSID = dbo.StatDate.Int_FSID ON #tmpEmployees.STID = dbo.StatDate.Int_STID AND
#tmpEmployees.FLID = dbo.StatDate.Int_FLID LEFT OUTER JOIN
dbo.zStates ON dbo.StatDate.Int_STID = dbo.zStates.Int_STID ON dbo.Filings.Int_FLID = dbo.StatDate.Int_FLID LEFT OUTER JOIN
dbo.FilProgFnl INNER JOIN
dbo.zProgs ON dbo.FilProgFnl.Int_PRID = dbo.zProgs.Int_PRID ON dbo.Filings.Int_FLID = dbo.FilProgFnl.Int_FLID LEFT OUTER JOIN
dbo.zRequest ON dbo.Filings.Int_RBID = dbo.zRequest.Int_RBID'
-- end 12-19-2005

insert into #tmpFilings
EXECUTE ( @sqlFilings)

--The below query Returning 35+ million rows
Set @sqlFilingFrm = 'SELECT DISTINCT
#tmpFilings.FilingID, #tmpFilings.States AS [State Name], #tmpFilings.Title, #tmpFilings.EmpLName AS [Last Name],
#tmpFilings.EmpFName AS [First Name], #tmpFilings.EmpUserID, #tmpFilings.StatReqDate AS [Filing Sent to RS],
#tmpFilings.MailDate AS [Filing Sent to DOI], #tmpFilings.AppDate AS [Approved Date], #tmpFilings.Status,
#tmpFilings.Program, #tmpFilings.RequestBy, #tmpFilings.EffDate, #tmpFilings.REffDate, #tmpFilings.BrthDate, #tmpFilings.FLID,
#tmpFilingFrmLOBs.LOB, #tmpFilings.STID, #tmpIdentityForms.Type,#tmpFilingFrmLOBs.Int_LBID
FROM #tmpFilingFrmLOBs INNER JOIN
#tmpFilings ON #tmpFilingFrmLOBs.FLID = #tmpFilings.FLID AND #tmpFilings.STID = #tmpFilingFrmLOBs.Int_STID INNER JOIN
#tmpIdentityForms ON #tmpFilings.FLID = #tmpIdentityForms.FLID and #tmpFilings.STID = #tmpIdentityForms.Int_STID
WHERE (#tmpFilings.FLID LIKE ''FL0%'') OR
(#tmpFilings.FLID LIKE ''FL2%'')'
insert into #tmpFilingFrm
EXECUTE ( @sqlFilingFrm)

Set @sqlFilingRat = 'SELECT DISTINCT
#tmpFilings.FilingID, #tmpFilings.States AS [State Name], #tmpFilings.Title, #tmpFilings.EmpLName AS [Last Name],
#tmpFilings.EmpFName AS [First Name], #tmpFilings.EmpUserID, #tmpFilings.StatReqDate AS [Filing Sent to RS],
#tmpFilings.MailDate AS [Filing Sent to DOI], #tmpFilings.AppDate AS [Approved Date], #tmpFilings.Status,
#tmpFilings.Program, #tmpFilings.RequestBy, #tmpFilings.EffDate, #tmpFilings.REffDate, #tmpFilings.BrthDate, #tmpFilings.FLID,
#tmpFilingRatLOBs.LOB, #tmpFilings.STID, #tmpIdentityRates.Type,#tmpFilingRatLOBs.Int_LBID
FROM #tmpFilingRatLOBs INNER JOIN
#tmpFilings ON #tmpFilingRatLOBs.FLID = #tmpFilings.FLID AND #tmpFilings.STID = #tmpFilingRatLOBs.Int_STID INNER JOIN
#tmpIdentityRates ON #tmpFilings.FLID = #tmpIdentityRates.FLID and #tmpFilings.STID = #tmpIdentityRates.Int_STID
WHERE (#tmpFilings.FLID LIKE ''FL0%'') OR
(#tmpFilings.FLID LIKE ''FL2%'')'
insert into #tmpFilingRat
EXECUTE ( @sqlFilingRat)

Set @sqlFilingRul = 'SELECT DISTINCT
#tmpFilings.FilingID, #tmpFilings.States AS [State Name], #tmpFilings.Title, #tmpFilings.EmpLName AS [Last Name],
#tmpFilings.EmpFName AS [First Name], #tmpFilings.EmpUserID, #tmpFilings.StatReqDate AS [Filing Sent to RS],
#tmpFilings.MailDate AS [Filing Sent to DOI], #tmpFilings.AppDate AS [Approved Date], #tmpFilings.Status,
#tmpFilings.Program, #tmpFilings.RequestBy, #tmpFilings.EffDate, #tmpFilings.REffDate, #tmpFilings.BrthDate, #tmpFilings.FLID,
#tmpFilingRulLOBs.LOB, #tmpFilings.STID, #tmpIdentityRules.Type,#tmpFilingRulLOBs.Int_LBID
FROM #tmpFilingRulLOBs INNER JOIN
#tmpFilings ON #tmpFilingRulLOBs.FLID = #tmpFilings.FLID AND #tmpFilings.STID = #tmpFilingRulLOBs.Int_STID INNER JOIN
#tmpIdentityRules ON #tmpFilings.FLID = #tmpIdentityRules.FLID and #tmpFilings.STID = #tmpIdentityRules.Int_STID
WHERE (#tmpFilings.FLID LIKE ''FL0%'') OR
(#tmpFilings.FLID LIKE ''FL2%'')'
insert into #tmpFilingRul
EXECUTE ( @sqlFilingRul)



The above store procedure takes more than 2 hours. There are two query that retrieve Returning 20+ million rows and Returning 35+ million rows. These things I have mention in the storeprocedure.
Can anyone please advise the best query to display fast.

Thanks & regards
Praveen
Go to Top of Page

praveen.paspulate
Starting Member

14 Posts

Posted - 2011-05-04 : 00:59:15
The above store procedure takes time in execution due to below query

--The below query Returning 20+ million rows

Set @sqlFilings = 'SELECT DISTINCT
TOP 100 PERCENT dbo.Filings.FilingID, dbo.zStates.StName, dbo.Filings.Title,
#tmpEmployees.LName, #tmpEmployees.FName, #tmpEmployees.UserID,
dbo.StatDate.MailDate, dbo.StatDate.AppDate, dbo.zProgs.Title, dbo.zFlngSts.Status,
dbo.zStates.Int_STID, dbo.zRequest.RequstBy, dbo.Filings.BrthDate, dbo.Filings.ReqDate, dbo.StatDate.ReqDate,
dbo.Filings.Int_FLID, dbo.StatDate.EffDate, dbo.StatDate.REffDate,
#tmpIdentity.LOB, #tmpIdentity.Type,#tmpIdentity.LBPR
FROM #tmpIdentity RIGHT OUTER JOIN
dbo.Filings ON #tmpIdentity.FLID = dbo.Filings.Int_FLID LEFT OUTER JOIN
#tmpEmployees RIGHT OUTER JOIN
dbo.zFlngSts INNER JOIN
dbo.StatDate ON dbo.zFlngSts.Int_FSID = dbo.StatDate.Int_FSID ON #tmpEmployees.STID = dbo.StatDate.Int_STID AND
#tmpEmployees.FLID = dbo.StatDate.Int_FLID LEFT OUTER JOIN
dbo.zStates ON dbo.StatDate.Int_STID = dbo.zStates.Int_STID ON dbo.Filings.Int_FLID = dbo.StatDate.Int_FLID LEFT OUTER JOIN
dbo.FilProgFnl INNER JOIN
dbo.zProgs ON dbo.FilProgFnl.Int_PRID = dbo.zProgs.Int_PRID ON dbo.Filings.Int_FLID = dbo.FilProgFnl.Int_FLID LEFT OUTER JOIN
dbo.zRequest ON dbo.Filings.Int_RBID = dbo.zRequest.Int_RBID'
-- end 12-19-2005

insert into #tmpFilings
EXECUTE ( @sqlFilings)


--The below query Returning 35+ million rows
Set @sqlFilingFrm = 'SELECT DISTINCT
#tmpFilings.FilingID, #tmpFilings.States AS [State Name], #tmpFilings.Title, #tmpFilings.EmpLName AS [Last Name],
#tmpFilings.EmpFName AS [First Name], #tmpFilings.EmpUserID, #tmpFilings.StatReqDate AS [Filing Sent to RS],
#tmpFilings.MailDate AS [Filing Sent to DOI], #tmpFilings.AppDate AS [Approved Date], #tmpFilings.Status,
#tmpFilings.Program, #tmpFilings.RequestBy, #tmpFilings.EffDate, #tmpFilings.REffDate, #tmpFilings.BrthDate, #tmpFilings.FLID,
#tmpFilingFrmLOBs.LOB, #tmpFilings.STID, #tmpIdentityForms.Type,#tmpFilingFrmLOBs.Int_LBID
FROM #tmpFilingFrmLOBs INNER JOIN
#tmpFilings ON #tmpFilingFrmLOBs.FLID = #tmpFilings.FLID AND #tmpFilings.STID = #tmpFilingFrmLOBs.Int_STID INNER JOIN
#tmpIdentityForms ON #tmpFilings.FLID = #tmpIdentityForms.FLID and #tmpFilings.STID = #tmpIdentityForms.Int_STID
WHERE (#tmpFilings.FLID LIKE ''FL0%'') OR
(#tmpFilings.FLID LIKE ''FL2%'')'
insert into #tmpFilingFrm
EXECUTE ( @sqlFilingFrm)

The above two queries taking above 3 hours of execution. Can anyone please help me...
Go to Top of Page
   

- Advertisement -