SQL: Issue with running out of storage on server when running table-valued function

SQL Version: 2008 (not r2)
Problem:  I'm getting the following error message when running a table-valued function:
Msg 1105, Level 17, State 2, Line 1
Could not allocate space for object 'dbo.SORT temporary run storage:  141072001204224' in database 'tempdb' because the 'PRIMARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files
to the filegroup, or setting autogrowth on for existing files in the filegroup.
Request:  Could anyone tell me if there are modifications that I could make to my SQL code to avoid this storage issues?
Thanks,
....bob sutor
Code Facts:
The JCCD table is a large table 2MM records
The other tables in the JOINS are very small 15 records or less
SQL Function Code:
ALTER FUNCTION [dbo].[xcft_XAWP_GLBalance_JCCD_Detail]()
RETURNS @JCGLDetail TABLE
      JCCo tinyint
    , Job varchar(10)
    , PostingSource varchar(10)
    , CostToDate numeric(12,2)
    , Phase varchar(20)
    , EarnType smallint
    , LiabilityType smallint
    , CostType tinyint
    , ControllingSetting varchar(30)
    , GLAccountCharged varchar(20)
    , DeptNum varchar(10)
    , DeptDesc varchar(30)
    , JCDC_CostType tinyint
    , CostTypeGL_Open varchar(20)
    , CostTypeGL_Closed varchar(20)
    , JCDO_ExcludePR varchar(1)
    , JCDO_Phase varchar(20)
    , PhaseGL_Open varchar(20)
    , PhaseGL_Closed  varchar(20)
    , JCDL_LiabType smallint
    , LiabTypeGL_Open varchar(20)
    , LiabTypeGL_Closed varchar(20)
    , JCDE_EarnType smallint
    , EarnTypeGL_Open varchar(20)
    , EarnTypeGL_Closed varchar(20)
AS
BEGIN
 DECLARE
 @WIPMonthCurrent date
 SET @WIPMonthCurrent = (Select TOP 1 WIPMonth FROM udxcWIPMonths WHERE ActiveWIPPeriod = 'Y')
 INSERT INTO @JCGLDetail
      JCCo
    , Job
    , PostingSource
    , CostToDate
    , Phase
    , EarnType
    , LiabilityType
    , CostType
    , DeptNum
    , DeptDesc
    , JCDC_CostType
    , CostTypeGL_Open
    , CostTypeGL_Closed
    , JCDO_ExcludePR
    , JCDO_Phase
    , PhaseGL_Open
    , PhaseGL_Closed
    , JCDL_LiabType
    , LiabTypeGL_Open
    , LiabTypeGL_Closed
    , JCDE_EarnType
    , EarnTypeGL_Open
    , EarnTypeGL_Closed
 SELECT  
     JCCD.JCCo, JCCD.Job, JCCD.Source, sum(JCCD.ActualCost) AS CostToDate, JCCD.Phase, JCCD.EarnType, JCCD.LiabilityType, JCCD.CostType
   , JCDM.Department, JCDM.Description
   , JCDC.CostType AS JCDC_CostType, JCDC.OpenWIPAcct AS CostTypeGL_Open, JCDC.ClosedExpAcct AS CostTypeGL_Closed
   , JCDO.ExcludePR AS JCDO_ExcludePR, JCDO.Phase AS JCDO_Phase, JCDO.OpenWIPAcct AS PhaseGL_Open, JCDO.ClosedExpAcct AS PhaseGL_Closed
   , JCDL.LiabType AS JCDL_LiabType, JCDL.OpenBurdenAcct AS LiabTypeGL_Open, JCDL.ClosedBurdenAcct AS LiabTypeGL_Closed
   , JCDE.EarnType AS JCDE_EarnType, JCDE.OpenLaborAcct AS EarnTypeGL_Open, JCDE.ClosedLaborAcct AS EarnTypeGL_Closed
 FROM JCCD
 LEFT JOIN JCJP ON JCCD.JCCo = JCJP.JCCo AND JCCD.Job = JCJP.Job
 LEFT JOIN JCCM ON JCJP.JCCo = JCCM.JCCo AND JCJP.Contract = JCCM.Contract
 LEFT JOIN JCDM ON JCCM.JCCo = JCDM.JCCo AND JCCM.Department = JCDM.Department
 LEFT JOIN JCDC ON JCDM.JCCo = JCDC.JCCo AND JCDM.Department = JCDC.Department AND JCCD.CostType = JCDC.CostType
 LEFT JOIN JCDE ON JCDM.JCCo = JCDE.JCCo AND JCDM.Department = JCDE.Department AND JCCD.EarnType = JCDE.EarnType
 LEFT JOIN JCDO ON JCDM.JCCo = JCDO.JCCo AND JCDM.Department = JCDO.Department AND JCCD.Phase = JCDO.Phase
 LEFT JOIN JCDL ON JCDM.JCCo = JCDL.JCCo AND JCDM.Department = JCDL.Department AND JCCD.LiabilityType = JCDL.LiabType
 LEFT JOIN xcft_XAWP_FiscalPeriodCutoffs_ForWIPMonth() AS cutoffs ON JCCD.JCCo = cutoffs.GLCo
 WHERE
      JCCD.Mth <= cutoffs.FiscalYear_LastMonth
     AND JCCD.Job IN(SELECT JobNum FROM budxcWIPData_SQL WHERE WIPMonth = @WIPMonthCurrent)
     AND JCCD.JCCo IN(SELECT JCCo FROM JCCO WHERE udExcludeFromWIP <> 'Y' or udExcludeFromWIP IS NULL)
     --AND LTRIM(RTRIM(JCCD.Job)) = '71-'
 GROUP BY
     JCCD.JCCo, JCCD.Job, JCCD.Source, JCCD.Phase, JCCD.EarnType, JCCD.LiabilityType, JCCD.CostType
   , JCDM.Department, JCDM.Description
   , JCDC.CostType, JCDC.OpenWIPAcct, JCDC.ClosedExpAcct
   , JCDO.ExcludePR, JCDO.Phase, JCDO.OpenWIPAcct, JCDO.ClosedExpAcct
   , JCDL.LiabType, JCDL.OpenBurdenAcct, JCDL.ClosedBurdenAcct
   , JCDE.EarnType, JCDE.OpenLaborAcct, JCDE.ClosedLaborAcct
 UPDATE @JCGLDetail
  SET
      ControllingSetting =
    CASE WHEN Phase = JCDO_Phase AND JCDO_ExcludePR = 'N' THEN 'PhaseOverride-PR Excluded'
      WHEN Phase = JCDO_Phase AND JCDO_ExcludePR = 'Y'
       AND EarnType NOT IN(Select EarnType FROM JCDE WHERE JCDE.JCCo = JCCo AND JCDE.Department = DeptNum)
       AND LiabilityType NOT IN(Select LiabType FROM JCDL WHERE JCDL.JCCo = JCCo AND JCDL.Department = DeptNum)
       THEN 'PhaseOverride-PR Not Excluded'
      WHEN EarnType = JCDE_EarnType THEN 'Earn Type Override'
      WHEN LiabilityType = JCDL_LiabType THEN 'Liability Type Override'
      ELSE 'Cost Type' END
 UPDATE @JCGLDetail
  SET
      GLAccountCharged =
    CASE WHEN ControllingSetting = 'PhaseOverride-PR Excluded' OR ControllingSetting = 'PhaseOverride-PR Not Excluded'
      THEN PhaseGL_Open
      WHEN ControllingSetting = 'Earn Type Override' THEN EarnTypeGL_Open
      WHEN ControllingSetting = 'Liability Type Override' THEN LiabTypeGL_Open
      ELSE CostTypeGL_Open END
RETURN 
END
Bob Sutor

well, did you either restart the instance or add another tempdb file (no restart required) to let other transactions  continue on the server.
or check if autogrowth was limited, change that to unlimnited , to the transactions conintue..
the function may be dumping the data on to tempdb, how much data are you excepting back...what are indexes on the tables
Hope it Helps!!

Similar Messages

  • Why does my IPhone 4 tell me that it can't back up onto icloud as it has run out of storage space, but when i look at iCloud storage it tells me I have 4.7GB out of 5GB available?

    Why does my I-Phone 4 tell me that it can't back up onto i-Cloud as it has run out of storage space, but when I look at i-Cloud storage it tells me I have 4.7GB out of 5GB available?

    Welcome to the Apple Community.
    Have you checked how much space the backup will need.

  • Issue with uploading XML file from application server into internal table

    i Need to fetch the XML file from the application server and place into internal table and i am getting error message while using the functional module   SMUM_XML_PARSE and the error message is "line   1 col   1-unexpected symbol; expected '<', '</', entity reference, character data, CDATA section, processing instruction or comment" and could you please let me know how to resolve this issue?  
        TYPES: BEGIN OF T_XML,
                 raw(2000) TYPE C,
               END OF T_XML.
    DATA:GW_XML_TAB TYPE  T_XML.
    DATA:  GI_XML_TAB TYPE TABLE OF T_XML INITIAL SIZE 0.
    DATA:GI_STR TYPE STRING.
    data:  GV_XML_STRING TYPE XSTRING.
    DATA: GI_XML_DATA TYPE  TABLE OF SMUM_XMLTB INITIAL SIZE 0.
    data:GI_RETURN TYPE STANDARD TABLE OF BAPIRET2.
        OPEN DATASET LV_FILE1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.
        IF SY-SUBRC NE 0.
          MESSAGE 'File does not exist' TYPE 'E'.
        ELSE.
          DO.
    * Transfer the contents from the file to the work area of the internal table
            READ DATASET LV_FILE1 INTO GW_XML_TAB.
            IF SY-SUBRC EQ 0.
              CONDENSE GW_XML_TAB.
    *       Append the contents of the work area to the internal table
              APPEND GW_XML_TAB TO GI_XML_TAB.
            ELSE.
              EXIT.
            ENDIF.
          ENDDO.
        ENDIF.
    * Close the file after reading the data
        CLOSE DATASET LV_FILE1.
        IF NOT GI_XML_TAB IS INITIAL.
          CONCATENATE LINES OF GI_XML_TAB INTO GI_STR SEPARATED BY SPACE.
        ENDIF.
    * The function module is used to convert string to xstring
        CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
          EXPORTING
            TEXT   = GI_STR
          IMPORTING
            BUFFER = GV_XML_STRING
          EXCEPTIONS
            FAILED = 1
            OTHERS = 2.
        IF SY-SUBRC <> 0.
          MESSAGE 'Error in the XML file' TYPE 'E'.
        ENDIF.
      ENDIF.
      IF GV_SUBRC = 0.
    * Convert XML to internal table
        CALL FUNCTION 'SMUM_XML_PARSE'
          EXPORTING
            XML_INPUT = GV_XML_STRING
          TABLES
            XML_TABLE = GI_XML_DATA
            RETURN    = GI_RETURN.
      ENDIF.
      READ TABLE GI_RETURN TRANSPORTING NO FIELDS WITH KEY TYPE = 'E'.
      IF SY-SUBRC EQ 0.
        MESSAGE 'Error converting the input XML file' TYPE 'E'.
      ELSE.
        DELETE GI_XML_DATA WHERE TYPE <> 'V'.
        REFRESH GI_RETURN.
      ENDIF.

    Could you please tel me  why the first 8 lines were removed, till <Soap:Body and also added the line <?xml version="1.0" encoding="UTF-8"?> in the beggining .
    Becuase there will be lot of  XML files will be coming from the Vendor daily and that should be uploaded in the application server and should update in the SAP tables based on the data in the XML file.
    what information i need to give to vendor that do not add the first 8 lines in the XML file and add the line in the beggining <?xml version="1.0" encoding="UTF-8"?>   ??????
    Is there any other way we can do with out removing the lines?

  • Issues with WebDav over SSL via Terminal Server when Accessing SharePoint 2013

    Hi All,
    We have deployed a terminal server from which multiple users access and heavily use SharePoint 2013 (hosted on a separate server). The SharePoint site is published to the internet and is operating over an SSL certificate. Over the last few months we have
    been encountering a randomly occurring issue where all the users become unable to use Open with Explorer or mapped drives to access the site. During this time they can still access the site through the browser OK and download files etc. This issue sometimes
    reoccurs every few days, although at points it hasn't occurred for a couple of weeks before resurfacing.
    Current Terminal Server Config
    TS 2008 R2 Enterprise
    Site added to Trusted Sites. (have checked during broken time and still recognized as trusted)
    Using IE 11, site added as compatibility view
    Registries updated as below
    reg add HKLM\SYSTEM\CurrentControlSet\Services\WebClient\Parameters /v AuthForwardServerList /t REG_MULTI_SZ /d "*.clientsite.com"
    reg add HKLM\SYSTEM\CurrentControlSet\Services\WebClient\Parameters /v BasicAuthLevel /t REG_DWORD /d 2 /f
    reg add HKCU\Software\Microsoft\Office\14.0\Common\Internet /v BasicAuthLevel /t REG_DWORD /d 2 /f
    registry added for tabprocgrowth added to 2
    My test result are below:
             Restarting the SharePoint server or the terminal server will resolve the behaviour
    until the issue occurs again.
    Users on the terminal server can still open the
    ttps://clientsite2.harrierhc.com
    URL (this url is bound to the same UCC cert) with open with explorer during this time.
    While users are unable to access the ttps://clientsite.harrierhc.com
    URL, if they access the same site from WebDAV with a separate binding (e.g. ttp://clientsite the behaviour works fine.
    All other users not on the terminal server can still use the open with explorer behaviour during this time.
    IIS reset on the SP Server & restarting the web client service on the terminal server have no impact
    Reimporting the IIS certs have no impact
    There are numerous errors in both server’s event logs but none at the time of the issue instigation.
    Clearing the IE cached certificates has no impact
    Going to IE properties for the site and clicking the ‘Install Certificate’ has no impact
     Any ideas or suggestions would be much appreciated. If you need any more info let me know. (sorry for the ttps:// links cant be posted until my account is verified?
    Thanks again

    Hiya,
    are there any load balancers involved?

  • ICloud "running out of storage space"?

    Recently, iCloud is sending messages that I am running out of storage space. It says I have used 4.8GB out of the 5GB available to me. However, the storage space by apps does not add up to the shown used space.
    How do I resolve this problem?

    Hello Deldelcai
    If you are having issues with your iCloud storage, then take a look on your iOS device and look to see if you have any back ups that may be taking up that space. Check out the article below for more information.
    iCloud: Troubleshooting creating an iCloud backup
    http://support.apple.com/kb/TS3992
    Regards,
    -Norm G

  • Message: You will run out of storage when your downgrade takes effect

    In my email, I received a message today with the subject
    You will run out of storage when your downgrade takes effect
    I looked in my account and don't see anywhere where I've set it to downgrade. It's still set at the correct level. I checked the credit card to make sure it hadn't expired.
    Any thoughts of what else I could check?
    Here's the email:
    As requested, your iCloud storage will be downgraded to 5 GB on 02/27/2015. However, you are currently using 6 GB.
    Unless you take action before your downgrade takes effect, backups to iCloud will stop, and apps will no longer be able to save documents to iCloud. You can either free up storage or cancel your downgrade to keep your current storage plan for another year.
    To continue using these iCloud features without interruption, you can cancel your downgrade by selecting a different storage plan:
    1.
    On your iOS device, go to Settings and tap iCloud
    2.
    Tap Account.
    3.
    Tap your current plan, then choose from the options presented
    For more information on managing your iCloud storage, please read this Learn how to manage your iCloud storage >.
    The iCloud Team

    Sounds to me like you're not the original owner of the device.
    Did you buy it secondhand? From where?
    ~Lyssa

  • I am trying to edit my music list and then sync it to my iPhone 5 so I don't run out of storage space. However, I see the check marks on the iTunes library but am unable to uncheck them? How do I manually edit what will be synced to my phone?

    I am trying to edit my music list and then sync it to my iPhone 5 so I don't run out of storage space. However, I see the check marks on the iTunes library but am unable to uncheck them? How do I manually edit what will be synced to my phone? (the check marks are not bolded, does this mean they are not in my library but only on my phone?)

    You uncheck the music in your iTunes library on your computer and along with sync only checked songs and videos selected under the Summary selection for your iPhone sync preferences with iTunes, only checked songs in your iTunes library will be transferred to your iPhone or remain on your iPhone and the unchecked songs in your iTunes library that are currently on your iPhone will be removed when syncing.
    Or make use of iTunes playlists and choose selected playlists, albums, artists under the Music selection for your iPhone sync preferences with iTunes and select the playlists below that you want transferred to your iPhone.

  • Macbook air running out of storage

    I am relatively new to the mac world.  I have a macbook air 128g and am running out of storage space.  I am wondering if I can use icloud as a primary storage for my media files (Photos, music, video, etc).  Then I could potentially remove from hard drive to free up space.  I am concerned if this is possible and what the cons would be.  I am thinking that Itunes library and photos would not be as quickly accesible as it would be using the hard drive.  Please help...

    Winston Churchill wrote:
    Welcome to the Apple Community.
    iCloud can't be used for storage in that way. I believe sugarsync allows you to keep files online without having to have them on your hard drive.
    A slightly fuller explanation here, you can keep files without having them on your hard drive by using SugarSync's 'Web Archive' Storing them in any other SugarSync location will cause them to be synchronized with your computer, a bad thing if you want to delete them from the the local storage.

  • I am receiving a notification that says that I am running out of storage space. I backed up time mating to an external hard drive. Can I delete some files to make room?

    I am receiving notifications that I am running out of storage space. I backed up my mac book using an external and time machine. Can I delete some files to make room?
    If so,
    When I want to restore from my time machine, can I pick and choose, say certain songs, photos or documents?

    About TM "Backup Drive is Full"
    Alert TM only deletes older files if they have been deleted from the source and when TM needs space on the backup drive for a new incremental backup. Time Machine "thins" it's backups; hourly backups over 24 hours old, except the first of the day; those "daily" backups over 30 days old, except the first of the week. The weeklies are kept as long as there's room.
    So, how long a backup file remains depends on how long it was on your Mac before being deleted, assuming you do at least one backup per day. If it was there for at least 24 hours, it will be kept for at least a month. If it was there for at least a week, it will be kept as long as there's room.
    Note, that on a Time Capsule the sparsebundle grows in size as needed, but doesn't shrink. Thus, from the user's view of the TC it appears that no space has been freed, although there may be space in the sparsebundle.
    Once TM has found it cannot free up enough space for a new backup it reports the disk is full. You can either erase the backup drive and start your backups anew or replace the drive with a larger drive. You can also use the Time Machine application to selectively remove files, but that may be ineffective if you have to free up GBs of space.

  • How do i back up my photos from my iphone 6 then delete them from my device as i am running out of storage

    i have the iphone 6 16gb and am running out of storage, i would like to some how back up all my photos off my device and then delete all the photos off my iphone, does anybody have any idea if this is at all possible

    Hi DukeFrank,
    Welcome to Apple Support Communities. 
    The process of freeing up space on a device varies depending on the computer or services you’re using, but the article below should help you solve the issue of removing photos from your iPhone 6 in order to free up space and archive the photos.
    Import photos and videos from your iPhone, iPad, or iPod touch to your Mac or Windows PC - Apple Support
    Cheers,
    -Jason

  • My iPad keeps showing a message that I have run out of storage space.  I purchased more iCloud space in settings, but this message is still showing.  It also won't sync when I plug in to my computer...??

    My iPad keeps showing a message that I have run out of storage space.  I have purchased more iCloud space in settings, but I am still getting this message.  I also am not able to sync my iPad in iTunes when plugging in to my computer.

    The storage space is the iPad storage space, not iCloud storage space. What size Ipad do you have?
    How much space is your Other using? You may be able to reduce.
    How Do I Get Rid Of The “Other” Data Stored On My iPad Or iPhone?
    http://tinyurl.com/85w6xwn
    With an iOS device, the “Other” space in iTunes is used to store things like documents, settings, caches, and a few other important items. If you sync lots of documents to apps like GoodReader, DropCopy, or anything else that reads external files, your storage use can skyrocket. With iOS 5, you can see exactly which applications are taking up the most space. Just head to Settings > General > Usage, and tap the button labeled Show All Apps. The storage section will show you the app and how much storage space it is taking up. Tap on the app name to get a description of the additional storage space being used by the app’s documents and data. You can remove the storage-hogging application and all of its data directly from this screen, or manually remove the data by opening the app. Some applications, especially those designed by Apple, will allow you to remove stored data by swiping from left to right on the item to reveal a Delete button.
     Cheers, Tom

  • I'm running out of storage

    I have a 16gb iPad Air with IOS8.0.2 and am running out of storage space.  I have deleted everything I can think of,. In settings I see my apps are using only 167mbs, but in iTunes when I did a back up  it shows that the bulk of the storage is being used by "other".  What could that be and how do I clear it?

    I've found that the biggest space grabbers are Photos, Podcasts, Magazines, Music, Movies, TV Shows, and iBooks ... so, I would check those and eliminate what you don't want to keep on your iPad. I've got 20 GB with just two - Photos and Podcasts.
    ALSO go to usage in the settings and see what apps may be way too large to keep on your iPad for how little you may be using them. It's under "Manage Storage" in the middle section of the window, when you get there.
    I've got a 64 GB iPad and I'm still running out of room. I guess I'll have to go for the 128 GB one next time ... :-) ...

  • I have 54.84 GB available out of 55GB storage. Yet I get e mails warning me that i am running out of storage??

    I have 54.84 GB of storage available out of 50GB on my i cloud account. Yet i keep getting e mails from i cloud warning me that i am running out of storage. I bought £70 of extra storage to try and sort out this problem, but to no avail. Please tell me what to do!

    The problem could be that you don't have enough storage on the device itself, not on iCloud.  Go to Settings>General>Usage to see how much "Storage" you have available on the device.  Farther down the list is the available storage on iCloud.
    Also check:
    Go to Settings>iCloud>Storage & Backups>Manage Storage; there, tap the device you need info on and the resulting screen lists Backup Options with which apps store data on iCloud as well.
    A device needs many MB of storage in order to perform a backup to iCloud.
    Also see:  http://support.apple.com/kb/ht4847`

  • Early 2008 iMac mysteriously running out of storage

    Running out of storage.  I have a Early 2008 iMac desktop with 2GB of memory, L2 Cache of 6 MB.  Using OS X 10.8.5   I have only 4.11 GB free of 319.21 GB.  Referencing the More about this Apple storage tab, it says my largest user of memory is "other" which uses uses 279 GB. By contrast my photos uses 1.58GB, Audio 4.13 GB. Movies 10.7 GB, Apps 7.95 GB, Backup 0.  It seems obvious that OTHER is eating up all of the space.  I cannot figure out what this catagory is.  I assume it is the OS X system, but that cannot be that big. Does anyone have advice.
    I also have a Seagate Backup Plus drive of 2 TB where I back up my iMac.  It has 1.59TB free of its 2 TB capacity
    Also would adding another 2 GB in memory be advised.  Thanks for your help from a Senior Citizen with limited understanding of how my computer works internally.

    This was very helpful SO FAR.  At first I only found lots of little things to delete but it made little difference in the total memory gained.  The I realized I was only scanning my files.  I rescanned with it looking at only my hard drive and I got the result with 80% of the visual filled with big and small units lmost all appear to be Backup/Home Folder?    /INcremental.  The files date from 1/1/2012 until 11/11/2013.  Everything should be backing up to my SeaGate external drive.  Should I now delete or trash these older files and how do I do that?

  • Running out of storage on my ipad2

    i am running out of storage on my ipad. i don't think i have a lot of stuff on my pad but my pad is telling me different. i recently did the upgrade on my pad, did that take up storage????
    i really don't need all 2000 photos or 8 purchased videos  on my pad or on my phone for that matter. so my question.
    can i store all my photos and purchased videos  on my macbook pro only? then if i want to watch a video sync it back onto my pad watch it and then put it back on my mac? same thing with my photos. maybe only keep a few on my pad and phone.
    i do have icloud but really don't understand the full deal. but i don't need all the stuff that is on my mac on my pad and phone too.
    thanks so much for all and any help.

    thats my problem, i don't know how to do that. with the cloud, which i want to keep so that i can keep the "find my ipad, iphone and mac everything goes on all three.
    if i plug my ipad or iphone in it just duplicates what is already on there.
    so, i don't know how to just keep it in my mac and put it in the others when needed.
    i've been reading the support for icloud but i cannot find what i'm looking for.

Maybe you are looking for