T-SQL (SS2K8) :: Query With Several Joins Fills Up TempDB And Won't Finish

Aug 14, 2014

I have this query I need for a report. Originally it was 4 queries to be used in Crystal Reports. Now I want to create the same report with SSRS and therefore I incorporated all queries in one in order not to use subreports [URL].....

Tempdb fills up to nearly 90 GB. I am running SQL Server on a local box, so I am sure there is no other traffic. Here is the query:

SELECT AdHaupt.NSprache_ID
,AdHaupt.mengentext AS mengentextHaupt
,AdHaupt.Einzelpreis
,AdHaupt.Anzeigebezeichnung
,AdHaupt.Gesamtpreis

[Code] ...

I ran it with TOP 10 as well, just to see if it will finish at all, but it never did (ran for an hour now).

View 9 Replies


ADVERTISEMENT

Tempdb Grows Rapidly And Fills Up Disk Space

May 10, 2006

Hi,The tempdb file on one of our servers grew very large and used allavailable disk space. This is SQL Server 2000 SP4. I have installedhotfix version 8.00.2187. I opened a profiler trace but can't still getto the root of the problem. Any help will be appreciated.Egbon*** Sent via Developersdex http://www.developersdex.com ***

View 1 Replies View Related

T-SQL (SS2K8) :: Query Using Multiple APPLY Joins

Mar 20, 2014

I’ve never written a query with multiple APPLY joins before and I’m running into some troubles with my first one. The below SQL statement runs within 10 seconds if I comment out either one of the APPLY joins and its corresponding field columns. However, when I try to execute with both APPLY joins, the query runs indefinitely. The longest I’ve waited before cancelling it is 90 minutes.

Now, I know there are probably other ways I could write this query to get me the results I’m looking for. I’m posting this on the board because I’m curious about finding out why multiple APPLY joins could cause SQL Server to run away. I’m hoping to gain some insight so that I can better understand how APPLY joins work so that in case I have a big need to do this again in the future (without suitable workarounds) I can code it correctly.

Here are some things I’ve tried so far…

1.Changed the States table into a subquery that only returns a single state
2.Change all the references inside the APPLY subqueries so that they had different aliases (just in case they were conflicting with each other).
3.Changed the CROSS applies to OUTER applies. States has 50 records and only 32 have matching permit data so the 18 extra iterations using OUTER APPLY don’t impact performance any when an APPLY is used by itself.

SELECT s.state_name
, COUNT(DISTINCT DUPS.PermitNumber) AS NumOfDupPermits
, SUM(DistinctPermits) AS DistinctPermits
FROM States S
CROSS APPLY (SELECT w.StateID, COUNT(*) as DistinctPermits

[Code] ....

View 9 Replies View Related

T-SQL (SS2K8) :: Removing Not Necessary Joins In Child Query?

May 23, 2014

I am building a application, which will generates a MASTER query with 15 fields & 5 tables joins.Now, the user selects only some fields from that master fields and generates the CHILD query. This is creating a performance issue.

To minimize this, i would like to remove the not necessary joins in the child query.

View 8 Replies View Related

Does It Store All The Results To Tempdb Database When I Query Against A Large Table Which Joins Another Table?

Jun 25, 2007

Hi, all experts here,



I am wondering if tempdb stores all results tempararily whenever I query a large fact table with over 4 million records which joins another dimension table? Since each time when I run the query, the tempdb grows to nearly 1GB which nearly runs out all the space on my local system drive, as a result the performance totally down. Is there any way to fix this problem? Thanks a lot in advance and I am looking forward to hearing from you shortly for your kind advices.



With best regards,



Yours sincerely,



View 11 Replies View Related

How Do You Start A Query Running, But Don't Wait For It To Finish

Apr 6, 2001

Here's my dilema, I want to run a stored procedure that starts another stored procedure running, but does not wait for the stored procedure to complete execution.

The stored procedure should execute immediately, and leave the other procedure to complete running in the background. Is there any way to do this?

View 3 Replies View Related

SQL 2012 :: Compatibility Mode Causes Query Not To Finish

Aug 8, 2015

We recently upgraded out SQL version from SQL2008R2 to SQL2014. As such, the compatibility mode changed to SQL2104 (120).

We have several queries that used to run fine that now take forever to bring back results. There are no errors (which surprised me). They just take way too long now. PLus they seem to be causing high I/O and CPU.

If I change the compt level back to SQL2008 - these queries run fine.

QUERY with SQL2008 compt level - finished in 2 minutes.
QUERY with SQL2014 compt level - finishes in 3 hours 22 minutes.

same exact query - same server - only thing changed was compatibility level.

WHat do I look for in the queries that could be causing this? (they look fine but obviously I'm missing something here)..

View 9 Replies View Related

Tempdb Is Skipped. You Cannot Run A Query That Requires Tempdb

Jul 14, 2004

Has anyone seen the SQL Server error:

"tempdb is skipped. You cannot run a query that requires tempdb"?

We're running a .Net web application with a SQL Server 2000 backend, and we get the error intermittently. Restarting the SQL Server service seems to fix it, as it causes tempdb to be rebuilt, but this isn't a long term solution. Any direction or hints would be greatly appreciated. Thanks!
- Mike

View 11 Replies View Related

T-SQL (SS2K8) :: Getting Directory Information For Data / Log / TempDB / Backup

Nov 18, 2014

Is there an Admin script that yields the following directories?

Data
Data Root
Log
TempDB
Shared Feature
Backup

View 4 Replies View Related

Delete Fills Logs.

May 10, 2007

I'm trying to do a very large delete. I set the db to simple mode thinking that the Trans Log will not fill during the delete.

But it does still fill. I thought if you used simple mode the logs are not used?

Any thoughts?

View 1 Replies View Related

Delete Fills Logs.

May 10, 2007

I'm trying to do a very large delete. I set the db to simple mode thinking that the Trans Log will not fill during the delete.

But it does still fill. I thought if you used simple mode the logs are not used?

Any thoughts?

View 5 Replies View Related

Log File Fills HD In Minutes. Help!

Apr 9, 2008

Does anyone know what would cause my log file (.LDF) to grow at a rate of over 1MB per second and quickly fill up the hard drive? I could use a quick answer on this. My experience is in Oracle but I'm assuming you can set the maximum size for a log file for starters? Not sure why it would be growing at this rate anyway though. I could use some quick answers on this one. Thanks!

View 4 Replies View Related

Joins Query Help

Jun 4, 2007

Hi all,Just after some help with a query (Stored Procedure) I've managed to get wrapped round my head.The DB is as such:

COMPANY
Company_id
Company_name
COMPANY_GROUP
Group_id
Group_name
USER
User_id
User_name
Bridging tables

COMPANY_GROUP_BRIDGE
company_id
group_id

USER_COMPANY_BRIDGE
user_id
company_id Basically, the only parameter I have for the query is a User_id.I need to get the Group linked to the User and return all the companies within that group. I've
tried reading up on all the join types again but have just got this
completely wrapped round my neck. I keep thinking along the lines of
SELECT all the companies linked to all the groups linked to all the
companies linked to the User_id  :s  I must be able to do
this without using two Company tables...?
Any help much appreciated,Pete 

View 7 Replies View Related

Sub Query AND Inner Joins

Feb 25, 2008

I have 
Categories table with CategoryID, Title, CategoryParentID columns
Questions table with QuestionID, Text columns
CategoriesQuestions table with CategoryID, QuestionID columns
Now I want to make the query which takes QuestionID and return all Categories of that provided QuestionID.
I already have made that query in 2 different styles.
First I make an Inner Join to retrieve the results
Select Categories.* from Categories Inner Join CategoriesQuestiosn on Categories.CategoryID = CategoriesQuestions.CategoryID where CategoriesQuestions.QuestionID = 1
Second I make a sub query to retrive the results.
Select * from Categories where CategoryID In (Select CategoryID From CategoriesQuestions where QuestionID = 1)
Now I am asking what is the better one in respect to performance.
And please provide any other query if you have.

View 5 Replies View Related

Joins In A Query

Feb 26, 2014

Iwrote a query right, and need to get further information out of another table, so did a Join, but then also need to get further information out of another table..So, I need to add this query:

SELECT PERSONNUM as EmployeeCode
,[FIRSTNM] as Firstname
,[LASTNM] as LastName
,[HOMELABORLEVELDSC1] as Site
,[HOMELABORLEVELNM1] as SiteID
FROM [tkcsdb].[dbo].[VP_ALLPERSONV42]where USERACCOUNTSTATUS = 'active'
and homelaborlevelnm1 in ('11', '13', '32')
order by SiteID, LastName

To be included in this query:

SELECTa.PERSONNUM,
a.PERSONFULLNAME,
HOMELABORLEVELDSC1,
[SERVER]

[code]...

View 3 Replies View Related

Sql Query, Several Joins

Mar 6, 2008

I have the following:

select
ad.bank,ad.account_number,ad.account_short_name,
p.security_id,isnull(b.NAME,isnull(tw.name,ms.name)) as SecurityDescription,
p.security_price,mc.classcode,
sum(case
when p.security_price = 9999999.99900 then 0
when mc.classcode between '000'and'299' then (p.quantity * p.security_price) / 100
when mc.classcode between '950'and'999' then (p.security_price * p.quantity) * -1
when mc.classcode between '300' and '324' or mc.classcode between '330' and '399'then p.acm_ctf_mtf_price * p.quantity
when p.security_price = '0' then p.cost
else
(p.security_price * p.quantity)
end) as MV,p.position_date,p.quantity,p.cost,p.acm_ctf_mtf_price
from positions p
left join BloombergEquityData b on p.security_id = b.ID_CUSIP
left join account_detail ad on p.account_id = ad.account_id
left join metavanteclasscodes mc on p.security_id = mc.cusip
left join MacgregorSecurityMaster ms on p.security_id = ms.cusip
left join TobaSecurityWarehouse tw on p.security_id = tw.cusip
where p.position_date = '03/05/2008' and
((ad.investment_authority_id in ('2','3') and ad.bank in ('98','7R')) or ad.bank = '9W')-- and ad.account_number = '41G006012'
group byad.account_number,ad.account_short_name,p.security_id,
ms.name,b.NAME,p.security_price,p.position_date,ad.bank,mc.classcode,p.quantity,p.cost,p.acm_ctf_mtf_price,isnull(b.NAME,isnull(tw.name,ms.name))
order by ad.account_number,p.security_id

For a given day, in this example 3/5 if I were to just select all the records I would get back around 550,000. If I put the filter on where I tell it to just show me one account its snappy. If I remove that filter and have it show me all the accounts it take forever. Here is the layout of my positions table where i am pulling the majority of the information:

CREATE TABLE [dbo].[positions](
[account_id] [int] NOT NULL,
[security_id] [varchar](50) NOT NULL,
[position_date] [smalldatetime] NOT NULL,
[quantity] [decimal](18, 5) NOT NULL,
[cost] [decimal](18, 5) NULL,
[security_price] [decimal](18, 5) NULL,
[acm_ctf_mtf_price] [decimal](18, 9) NULL,
CONSTRAINT [PK_positions] PRIMARY KEY CLUSTERED
(
[account_id] ASC,
[position_date] ASC,
[security_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

My questions is if you can identify any reason why the query might take more than 10 minutes (actually still running after 10 minutes) to complete when I have it bring me back all the records, not sure if its a lack of indexes or what, but was hoping for some suggestions on what I might be missing. I apologize if I havent included enough information, still learning how to troubleshoot the performance side of things.

View 11 Replies View Related

SQL Server 2008 :: What Happens When The Xact Log Fills Up

May 5, 2015

how SQL handles a full transaction log. I'm running a population of a temp table with a lot of rows (roughly 70M), and when I run dbcc sqlperf(logspace) it says 99% of the tempdb log is full. It doesn't throw an error so is it still working? Does it have to do some sort of disk/memory swapping of the transaction log? Is occasionally filling-up of the xact log ok? Or is it something that has dire consequences for other operations as well?

View 3 Replies View Related

SQL Server Error Log Fills Disk

May 30, 2007

Hello,



I have the following problem:



I'am running SQL Server 2005 Express Advanced Services on a Windows 2003 Server in a hosted Environment. Some times SQL Server is beginning writing entries into C:ProgrammeMicrosoft SQL ServerMSSQL.1MSSQLLOGERRORLOG until the disk is full.. After that, I have to delete the error log file (some GB of size), restart the server and everything is running fine until the log file runs amok again.



I have installed SQL Server Management Studio.



With SQL server 2005 Standard I can configure or disable Error logging in the Management Studio. But with the Express Edition it seems that is not possible.



What I want to do is (maybe with system stored procedures)

limit number of error log files by cycling it, e.g. 5 files and delete the old ones
limit the size of one log file. e.g. 100 MB

Is there an option to configure this in the Express edition of SQL Server 2005?



Thanks in advance



Regards



Rolf

View 9 Replies View Related

Package Execution Fills C Drive

Mar 31, 2008



When I run an SSIS package that moves up to 2 GB of data from an ODBC source (FoxPro) to SQL Server a large temp file is created at:

c:Documents and SettingsusernameLocal SettingsTemp1filename.tmp

where username is obviously my domain user name, and filename is a seemingly random filename.

My C drive has limited space, but I have other local drives with plenty of space. Can I dictate where these temp files are created?

Thanks,
Chris

View 7 Replies View Related

Sql Joins Query Problem

Aug 30, 2006

Not sure if this is right place to ask but here is our problem. We are getting records from more than one table.  Table1 and Table2 for example Both Tables haveid, value table11, 201, 30 Table 21, 501, 40   here is the queryselect table1.id, table1.value, table2.value from Table1inner join Table2on Table1.id = table2.idproblem is this returns 4 rows like this1, 20 , 501, 30 , 501, 20 , 401, 30 , 40 When we need it to return1, 20 , null1, 30, null1, null, 401, null , 50 any help on this would be appreciated.Thank You in advance.  

View 2 Replies View Related

Slow Query With Joins And Where

Feb 5, 2008

Hi all.I want to use the following query in a sp to enable paging using ObjectDataSource.The problem (being EXTREMELEY slow) arises when I add these joins and where statements.
SELECT r.RID AS ReqID, r.Name AS ReqName, r.Family AS ReqFamily,t3.Name AS DistName, t4.Name AS RurName,t5.Name AS VilName, n.Name+' '+n.Family AS NazerName ,ROW_NUMBER() over (order by r.Family) AS RowRankFROM Requests rLEFT OUTER JOIN Nazeran n ON r.nazerID = n.ID LEFT OUTER JOIN t1States t1 ON t1.ID = r.StateID LEFT OUTER JOIN t2Provinces t2 ON t1.ID = t2.StateID AND r.ProvID = t2.ID LEFT OUTER JOIN t3Districts t3 ON t2.ID = t3.provID AND t1.ID = t3.stateID AND r.DistID = t3.ID LEFT OUTER JOIN t4RuralDistricts t4 ON t3.ID = t4.distID AND t2.ID = t4.provID AND t1.ID = t4.stateID AND r.RurID = t4.ID LEFT OUTER JOIN t5Villages t5 ON t4.ID = t5.rurID AND t3.ID = t5.distID AND t2.ID = t5.provID AND t1.ID = t5.stateID AND r.VilID = t5.IDWHERE r.stateid=(case when @StateID is null or @StateID='' then r.stateid else @StateID end)  and r.provid=(case when @provID is null or @provID='' then r.provid else @provID end)  and r.rID=(case when @ReqID is null or @ReqID='' then r.rID else @ReqID end)  and isnull(r.nazerID,'')=(case when @nazerID is null or @nazerID='' then isnull(r.nazerID,'') else @nazerID end)  and r.name+' '+r.family like (case when @ReqName is null or @ReqName='' then r.name+' '+r.family else '%'+@ReqName+'%' end)
**there are 1million rows in [Requests] table ,200000 rows in [t5villages], and about total 5000 rows in other tables.As you can see, this is for a GridView showing list of people requesting a loan allowing users to make alternative searches based on Name, Familyname ,ID ,...
would you please help me optimize and make fast this query.Many thanks..

View 13 Replies View Related

Two Outer-joins In One Query

Oct 5, 2003

I wrote a SQL query that firstly do an outer-join for two table and after I add another
table with outer-join as well.
I'm getting the following message:
Server: Msg 301, Level 16, State 1, Line 1
Query contains an outer-join request that is not permitted.
May be someone knows what is it?
If I remove the second join- it work....

View 2 Replies View Related

Complex Query, Many Joins...

May 1, 2008

Ok I have a complex query that works great, but now I need to join yet another table but the problem is, the value that links it to the rest of the query is a value that is returned from a case statement earlier in the query...

For Example...

SELECT var1, var2, var3,
CASE T1.Number WHEN 0 THEN T2.Result ELSE T3.Result END as var4
FROM TABLE1 T1
LEFT OUTER JOIN TABLE2 T2 on T2.Value=T1.Value
LEFT OUTER JOIN TABLE3 T3 on T3.Value=T1.Value2

Above is a generalized, much smaller example of my working Query.
Now what I need to do is join TABLE4 but the value I need to connect it to the rest of the query is var4, which can come from 2 different places depending on the value of T1.Number

Basically the logic I need to make it work is to either have a case statement in my JOIN. Like, 'LEFT OUTER JOIN TABLE4 on T4.Value=(CASE T1.Number WHEN 0 THEN T2.Result ELSE T3.Result END)'

Is this even possible and if so, how? I need to keep the logic in the main query to preserve performance...

Thank you in advance,

Casey

View 3 Replies View Related

How To Use Joins To Solve This Sql Query

Mar 27, 2008

My tables and data as follows

AB_Corporate_Project
Fields are : ab_crp_id , cust_name , owner_rep_id

Data in table AB_Corporate_Project is as follows

ab_crp_id cust_name owner_rep_id
1 harry 3
2 msas 2


AB_Plant_Project
Fields are : ab_plant_id , ab_name , owner_rep_id

Data in Table AB_Plant_Project

ab_plant_id ab_name owner_rep_id
1 abc 1
2 def 2

Other_Project
Fields are : other_proj_id,ot_name, owner_rep_id

Data in table Other_Project

other_proj_id ot_name owner_rep_id
1 xyz 2
2 cdf 3

Owner_Rep

Fields are : owner_rep_id,owner_name

Data in Table Owner_Rep

owner_rep_id owner_name
1 henry
2 hologa
3 tmw

Daily_Time_Entry
Fields are: dl_id,dt_id,project_type,project_id,time_st
Data in table Daily_Time_Entry

dl_id dt_id project_type project_id time_st
1 03/23/08 AB Corporate 1 1.20
2 03/23/08 AB Corporate 2 3.25
3 03/21/08 AB Corporate 1 2.25
4 03/23/08 AB Plant 1 4.35
5 03/23/08 AB Plant 2 4.50
6 03/23/08 Other Project 1 3.24
7 03/23/08 Other Project 2 4.35

I want to show records as per date from Daily_Time_Entry table and detail data to be displayed as follows

dl_id dt_id project_type project_id time_st exp1 exp2 exp3 owner_name
1 03/23/08 AB Corporate 1 1.20 3 -- -- tmw
2 03/23/08 AB Corporate 2 3.25 2 -- -- hologa
3 03/21/08 AB Corporate 1 2.25 3 -- -- tmw
4 03/23/08 AB Plant 1 4.35 -- 1 -- henry
5 03/23/08 AB Plant 2 4.50 -- 2 -- hologa
6 03/23/08 Other Project 1 3.24 -- -- 2 hologa
7 03/23/08 Other Project 2 4.35 -- -- 3 tmw

Also in project_type AB Corporate for AB_Corporate_Project, AB Plant for AB_Plant_Project , Other Project for Other_Project

I write query for this is as follows

Select dl. dl_id,dl.dt_id,dl.project_type,dl. project_id,dl.time_st,ac.owner_rep_id as exp1,ab. owner_rep_id as exp2,op. owner_rep_id as exp3,ow. owner_name
From Daily_Time_Entry dl left outer join
AB_Corporate_Project ac on dl. project_id = ac. ab_crp_id and dl. project_type=’ AB Corporate’ left outer join AB_Plant_Project ab on dl. project_id =ab. ab_plant_id and
dl. project_type=’ AB Plant’ left outer join Other_Project op on dl. project_id = op. other_proj_id and dl. project_type=’ Other Project’ inner join Owner_Rep ow on
(ow. owner_rep_id = ac. owner_rep_id) or(ow. owner_rep_id = ab. owner_rep_id)or
(ow. owner_rep_id = op.owner_rep_id)

So how can I write query to show output as follows or any other way or how to create Sql cursors for to show output
Plz help to solve this query to show output as specified.







uday

View 1 Replies View Related

Query Joins Problem

Jul 23, 2005

Hi all,I have the following tables:A1==HostID Name RunID------ ---- -----1 host1 NULL2 host2 13 host3 NULLA2==RunID SessionID----- ---------1 42 2A3==SessionID Name--------- ----4 Session12 Session3I want to show every record from A1 with SessionName from A3, unlessthe field RunID in A1 is NULL and then I want to see NULL, like this:HostID Name RunID Name------ ---- ----- ----1 host1 NULL NULL2 host2 1 Session13 host3 NULL NULLwhen I try the following query:select A1.*, A3.Namefrom A1, A2, A3where A1.RunId *= A2.RunId and A2.SessionID = A3.SessionIDI get the following error:The table 'A2' is an inner member of an outer-join clause. This is notallowed if the table also participates in a regular join clause.How can I overcome this problem. Please help. (I use this syntax isteadof joins since I have to supprt also Oracle DB and this syntax issimpler to translate).Thanks in advance,Yaron

View 1 Replies View Related

SQL View / Joins Query

Jul 23, 2005

Hi,I have a view(A) and I am trying to do a join on another table (B) toinclude only rows where date values in view A is greater than in tableB. I also want the view to pick up rows in viewA based on date values.Here is what I have so far:SELECT *FROM viewA vwleft JOIN tableB tb ONvw.id = tb.id and(vw.date1 > tb.date1 orvw.date2 > tb.date2 orvw.date3 > tb.date3)WHERE vw.date4 > getdate()-1Not matter what kind of join I use I can get both the rows from theview where dateA > getdate()-1 AND where date1-3 are greate than intableB. Dates 1 - 4 seperate date fields. Could someone please tellme what I am doing wrong.Thanks.

View 3 Replies View Related

Query With Joins Problem

Jun 22, 2006

HelloLet me explain the problem I am having:I have two tables, data_t and a_data_ta_data_t is the archive table of data_tThe two tables are exactly the same.In the table values are stored:Value (A numeric value)Code (A text code to identify a report with data)Line (The line number)Col (The Col Number)EDate (The date of entry)Grp (A number of a group the data belongs to)I want to get the value from data_t minus the value from a_data_t withthe same Code, Line and Col but with a different EDate (To view thevariance).Here is my statement:select d1.line, d1.col, (IsNull(d1.value,0) - IsNull(d2.value,0)) asvalue from data_t d1full outer join a_data_t d2 on d1.Code = d2.Code and d2.line = d2.lineand d1.col = d2.colwhered1.Code = 'XC001' and d1.line between 1 and 20 and d1.grp = 26and d1.EDate = '2006/06' and d2.grp = 26 and d2.EDate = '2006/05'order by d1.line, d1.colIt works fine EXCEPT when there is a value in either of the tables thatisn't in the other one, then a value is not given.Example:data_t doens't have a value for line=1 and col=2 and grp=26 and Code ='XC001' and EDate = '2006/06'a_data_t has the value of 50000 for the same details (Except Edate of'2006/5')Instead of returning -50000 it doesn't return anything.I hope I could explain it correctly.Any help will be greatly appreciated.Thanks.

View 1 Replies View Related

Using Joins How To Solve This Sql Query

Mar 27, 2008

My tables and data as follows

AB_Corporate_Project
Fields are : ab_crp_id , cust_name , owner_rep_id

Data in table AB_Corporate_Project is as follows

ab_crp_id cust_name owner_rep_id
1 harry 3
2 msas 2


AB_Plant_Project
Fields are : ab_plant_id , ab_name , owner_rep_id

Data in Table AB_Plant_Project

ab_plant_id ab_name owner_rep_id
1 abc 1
2 def 2

Other_Project
Fields are : other_proj_id,ot_name, owner_rep_id

Data in table Other_Project

other_proj_id ot_name owner_rep_id
1 xyz 2
2 cdf 3

Owner_Rep

Fields are : owner_rep_id,owner_name

Data in Table Owner_Rep

owner_rep_id owner_name
1 henry
2 hologa
3 tmw

Daily_Time_Entry
Fields are: dl_id,dt_id,project_type,project_id,time_st
Data in table Daily_Time_Entry

dl_id dt_id project_type project_id time_st
1 03/23/08 AB Corporate 1 1.20
2 03/23/08 AB Corporate 2 3.25
3 03/21/08 AB Corporate 1 2.25
4 03/23/08 AB Plant 1 4.35
5 03/23/08 AB Plant 2 4.50
6 03/23/08 Other Project 1 3.24
7 03/23/08 Other Project 2 4.35

I want to show records as per date from Daily_Time_Entry table and detail data to be displayed as follows

dl_id dt_id project_type project_id time_st exp1 exp2 exp3 owner_name
1 03/23/08 AB Corporate 1 1.20 3 -- -- tmw
2 03/23/08 AB Corporate 2 3.25 2 -- -- hologa
3 03/21/08 AB Corporate 1 2.25 3 -- -- tmw
4 03/23/08 AB Plant 1 4.35 -- 1 -- henry
5 03/23/08 AB Plant 2 4.50 -- 2 -- hologa
6 03/23/08 Other Project 1 3.24 -- -- 2 hologa
7 03/23/08 Other Project 2 4.35 -- -- 3 tmw

Also in project_type AB Corporate for AB_Corporate_Project, AB Plant for AB_Plant_Project , Other Project for Other_Project

I write query for this is as follows

Select dl. dl_id,dl.dt_id,dl.project_type,dl. project_id,dl.time_st,ac.owner_rep_id as exp1,ab. owner_rep_id as exp2,op. owner_rep_id as exp3,ow. owner_name
From Daily_Time_Entry dl left outer join
AB_Corporate_Project ac on dl. project_id = ac. ab_crp_id and dl. project_type=€™ AB Corporate€™ left outer join AB_Plant_Project ab on dl. project_id =ab. ab_plant_id and
dl. project_type=€™ AB Plant€™ left outer join Other_Project op on dl. project_id = op. other_proj_id and dl. project_type=€™ Other Project€™ inner join Owner_Rep ow on
(ow. owner_rep_id = ac. owner_rep_id) or(ow. owner_rep_id = ab. owner_rep_id)or
(ow. owner_rep_id = op.owner_rep_id)

So how can I write query to show output as follows or any other way or how to create Sql cursors for to show output
Plz help to solve this query to show output as specified.

<!--[endif]-->

View 1 Replies View Related

Memory Fills Up Then A Buffer Error Is Generated.

Jun 22, 2007

I have SSIS sp2 running on a Win2003 64bit Server with 4processors and 16GB of ram. I am trying to load 1 billion rows of data into 10 tables. The source data is found in 12 different 50GB fixed width flat files stored on 2 different files servers. The destination is 10 different tables in a single SQL Server 2000 database which has 1TB of space allocated to it. I use the MS SQL OLE DB connection for each destination table.



The SSIS package is pretty straight forward. Everything takes place in 1 data flow. The 12 sources each flow through 12 different Row Count Transformations into a single Union All Transformation. From the Union All transformation the data goes into another Row Count Transformation then into a Conditional Split Tranformation. The data is split into 10 streams base on the last digit of one of the ID fields in the data. The 10 streams are fed to the 10 destination tables.



Every time I run the package (Start without Debugging) the avaible physical memory goes from around 15GB to 0 in about 2 minutes. The % comitted bytes in use goes from 5% to 100% in about 5 minutes. Once at 100% it will stay there for around 5 minutes before it will finally give me the following error message:



The system reports 98 percent memory load. There are 17178939392 bytes of physical memory with 189382656 bytes free. There are 8796092891136 bytes of virtual memory with 8742748930048 bytes free. The paging file has 54388109312 bytes with 16056320 bytes free.



This message is followed by a bunch of other messages:



SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Union All" (2073) failed with error code 0x8007000E. The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure.


SSIS Error Code DTS_E_THREADFAILED. Thread "WorkThread1" has exited with error code 0x8007000E. There may be error messages posted before this with more information on why the thread has exited.
The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.


SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "Dr 2" (663) returned error code 0xC02020C4. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.
The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.


...



SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "Dr 3" (898) returned error code 0xC02020C4. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.


SSIS Error Code DTS_E_THREADFAILED. Thread "SourceThread2" has exited with error code 0xC0047038. There may be error messages posted before this with more information on why the thread has exited.



I have tried adjusting the Engine threads down from 5 to 4 to 2. I have tried adjusting the FastLoadMaxInsertCommitSize from 1000000 to 100000 to 1000 (Destinations are tablocked and Check Constraints). I have tried moving the DefaultBufferMax up to 16500 and down to 2000.



Nothing works. The package fails everytime within 20 minutes of its start.



I would prefer not to have to rewrite the package and process each file sequentially as that would take forever.



Any ideas would be greatly appreciated.



Thanks.

-Scott

View 5 Replies View Related

Writing Alternative Query For Inner Joins

Jun 19, 2007

Hello....
i have 4 tables in a databse(tab1,tab2,tab3,tab4). id is the attribute of TAB1 and id also foreign key of all the tables.....That mean id attribute exists on all the tables........so when i want to query to more than 1 table , i have to go for Joins...basically i am using innerjoin.........
Can u tell me is there any other way to find the same output as the innerjoin......without using the keyword INNER JOIN
for example ......SELECT * FROM TAB1 INNER JOIN (TAB2 INNERJOIN TAB3 ON TAB2.ID=TAB3.ID) ON TAB1.ID=TAB2.ID
 
another query........
SELECT *FROM TAB1,TAB2,TAB3 WHERE (TAB1.ID=TAB2.ID) AND (TAB2.ID=TAB3.ID) AND (TAB3.ID=TAB1.ID)
above queries are same or not??????????

View 1 Replies View Related

Joins Vs Where Clause - Performance Query

Dec 5, 2006

Hi There !!

To finetune performance for some of our queries,

I have come across suggestions to use

- JOINS instead of WHERE clause wherever possible
- and avoid using Aliases

Although Avoiding aliases looks reasonable I am yet to be convinced about JOINS replacing the WHERE CLAUSE . What is the experts take on this one ????

Also,

I checked the estimated plan in SQL server by running the following 2 queries into my Query Designer

tables : dba ( empid, empname )
project ( project_empid references dba.empid, project_name )


USING A WHERE CLAUSE and Alias
-------------------------
select a.emp_name from dbo.dba a, dbo.project b
where
a.empid =b.project_emp
and b.project_name is not null

USING A JOIN
-----------------
select emp_name from dbo.dba
as
a inner JOIN dbo.project
ON empid = dbo.project.project_emp
AND dbo.project.project_name is not NULL

******

I find from the Estimated plan that both the queries give the same amount of cost ( I/O, CPU, et all ) :shocked:

Any comments/ suggestions.

Thanks,

Have a great time
-Ranjit.

-------------------------------------
It pays to be honest to your DBA

View 4 Replies View Related

Query On Performing Recursive Joins

Apr 14, 2007

I have a single table named PROCESS which contain following three fields

ProcessID
ParentID,
info

* Every process have a unique ProcessID and ave single parent process which is identified by ParentID.

* If a process does not have a Parent then its ParentID value is -1.

*Only single level of Parent-child hierarchy is maintained.


Can anyone please tell me the Query that uses Recursive JOINS to retrieve the ProcessID s based in following Conditions.

1. if the Parent's 'info' field contains given value then retrieve all the process under it.
2. Retrive all the process whose 'info' contains given value and excluding the Processes resulted from 1st conditiion

Thanks in advance

Bharath Booshan L

View 2 Replies View Related

Query Optimization Assistance W/ Joins

Jul 20, 2005

I have a couple of tables that look like this (not excactly but closeenough):[Contact]id intfname varchar(50)lname varchar(50)[ContactPhoneNumber]id intnumber varchar(15)ext varchar(6)contact_id intpriority int (indicates primary, secondary... numbers)type int (indicates type of number: fax, cell, land line)I'm looking for a more optimized method of displaying this informationin this format:fname, primary business phoneUsing a derived column like this works, but seems to be slow with manyrecords, despite tuning indexes:SELECT c.fname AS [First Name],( SELECT TOP 1numberFROM ContactPhoneNumber cpnWHERE cpn.type = 1AND cpn.contact_id = c.idORDER BY cpn.priority) AS NumberFROM Contact cI can get the same results using a join, and it's a lot faster. But I'mnot sure how to select only the primary phone number this way...basically the first phone number whose priority is either NULL or 1.Any suggestions?*** Sent via Devdex http://www.devdex.com ***Don't just participate in USENET...get rewarded for it!

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved