This code only inserts the first column in the temp table

  • After I run this code and then run Select * from #TEMPSTP, i only get one Column.
    It worked at one point, but i'd rather not back up to that point.
    Thoughts? thanks 
    use GTM_ODS;

    -- drop table #Tempstp
    -- Select * from #Tempstp

    select * into #tempSTP from
    (Select
      P.PROD_ID
         ,D.SUPPLIER_ID
      , P.DESCRIPTION
      , P.ELIGIBILITY_FLG
      , P.CTRY_ORIGIN
      , P.RESPONSE_HS
      , P.COMPRESSED_PROD_ID
      , D.SOLICITATION_ID
      , D.SOLICITATION_TYPE
      , D.TRADE_PROGRAM
      , D.BLANKET_FROM_DATE
      , D.DOC_ID
      , D.CREATED_BY
      , D.CREATED_DATE
      , D.SOLICITED_YN
      , D.LAST_MODIFIED_DATE
      , D.STATUS as Doc_Status
      , D.REMINDER_SENT_DATE
      , D.RESPONSE_RECEIPT_DATE
      , D.AUDIT_PASS_YN
      , D.CLOSE_DATE
      , D.HS_MISMATCH
      , D.REQUEST_TYPE
         ,' ' as ZATS
    from
    [SOLICIT].[gtm_doc_Prod] P
    inner join
     [SOLICIT].[gtm_doc] D
    on
    D.[SOLICITATION_ID] = P.[SOLICITATION_ID]
      and D.[SUB_ORG] = P.[SUB_ORG]
      and D.[SOLICITATION_TYPE] = P.[SOLICITATION_TYPE]
    WHERE
      Datepart(year,d.BLANKET_FROM_DATE) = '2019'
      and D.SUB_ORG = 'XXXX'
      and D.SOLICITATION_TYPE = 'Response'
      and D.STATUS = 'CLOSED'
      and TRADE_PROGRAM like '%nafta%'
         and P.CTRY_ORIGIN in ('CA', 'MX')
         )
         as STP

  • SOLVED, thanks

  • jeffshelix - Monday, February 18, 2019 4:00 PM

    SOLVED, thanks

    So what was the problem?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply