0

I have Sequel server 2019 with databases on it and whenever running query on the database, the C: drive will lose space until I close out of the query and then it will regain it all.

I've tried running management studio from SQL server 2019 querying the databases and then C: drive constantly looses space until I close the query.

My C drive is 34 GB free space but data which I am running with 6 GB tables. I tried to change the settings on tools and SQL execution tab as well. Appreciate if someone can help with this.

Shaik
  • 1
  • 1
  • 1
    [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](https://meta.stackoverflow.com/q/326569/2029983) – Thom A May 04 '20 at 07:52
  • At least show us the query your running. A "simple" query won't use up additional disk space on your disc, unless it ends up writting a huge amount of the logs or tempdb; and if it's writing that much you're asking for a huge amount of data to be displayed or manipulated. – Thom A May 04 '20 at 07:54
  • Due to clients data I can't give the query here.I am using left join, join and union with 4 tables. I used to run the same query till yesterday night. Its giving problem now. – Shaik May 04 '20 at 08:04
  • Giving us a query doesn't expose any data. If you're not willing to tell us and show us *what* you're doing, then we can't help you. You wouldn't ask a mechnic to fix your car without looking at it; the same logic applies here. – Thom A May 04 '20 at 08:07
  • INSERT INTO [PLDTOTC2].[dbo].[PPA_FINAL] SELECT Distinct A._CASE_KEY,B._ACTIVITY,B._EVENTTIME,A.SR_SUMMARY_ID,B.SR_STATUS_MAPPED, '' as STATUS,'' as SOTYPE,A.ITYP,B.RATE_PLAN_DESC,B.SR_CRTR_REGION_CODE, B.SR_CRTR_WC_DESC,B.SALESCHANNEL,B.AGENT_CODE,A.BILL_STATUS, '' as NETYPE,'' as CONTREMPID,'' as RSO_REASON, '' as REGION,'' as PROVINCE, '' as CITY,'' as INSTALLATION_COUNT,B.SOURCE_APP,B.SR_CAN_REASON, A.KENAN_CAN_REASON FROM [PLDTOTC].[dbo].[KENAN_FINAL] A JOIN [PLDTOTC].[dbo].[CSP_Final] B ON TRIM(A.SR_SUMMARY_ID) = TRIM(B.SR_SUMMARY_ID) – Shaik May 04 '20 at 08:10
  • There is an [edit] feature, please use it, and put the query in your question. Comments can't be formatted, so that SQL is very difficult to read. – Thom A May 04 '20 at 08:15
  • My *best* guess, seeing as this is an `INSERT`, is that you are inserting a large amount of data and the transaction log is getting filled up. the `ON` clause won't be SARGable either, due to the `TRIM`, so I suggest fixing that (if your data if might have leading spaces in one table and not the other, I suggest fixing the data). Also, as a suide note: [https://sqlblog.org/2009/10/08/bad-habits-to-kick-using-table-aliases-like-a-b-c-or-t1-t2-t3](https://sqlblog.org/2009/10/08/bad-habits-to-kick-using-table-aliases-like-a-b-c-or-t1-t2-t3). There's no `B` in `CSP_Final`, so why alias it as `B`? – Thom A May 04 '20 at 08:19
  • The same query was running till last night. Just i added some data to A and B tables. Now also query is running without issues and ending due to low disc space. C drive is filling up from 34 GB to 0 bytes. Do you have any suggestion to change the settings? I tried all the ways but no luck. Thanks for your help. – Shaik May 04 '20 at 08:26
  • *"I tried all the ways but no luck"* If you had tried "all the ways", you wouldn't be having the issue. Details what you've tried. [edit] your question, like I've asked. – Thom A May 04 '20 at 08:46

1 Answers1

0

Check if join conditions in the query don't use aliases of the same table, like

TRIM(A.SR_SUMMARY_ID) = TRIM(A.SR_SUMMARY_ID) 

instead of

TRIM(A.SR_SUMMARY_ID) = TRIM(B.SR_SUMMARY_ID) 
David Buck
  • 3,752
  • 35
  • 31
  • 35
Alexander
  • 139
  • 8