Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2005
    Posts
    20

    Unanswered: RUNTIME ERROR- solution needed

    CREATE PROCEDURE ANNL_ARCHV @DATE VARCHAR(8) = NULL
    AS
    DECLARE @QUERY VARCHAR(1000)
    DECLARE @DEL_QUERY VARCHAR(200)
    DECLARE @TABLENAME VARCHAR(50)
    DECLARE @ENDTRD_DATE VARCHAR(50)
    DECLARE @YEAR VARCHAR(4)




    SELECT @YEAR = SUBSTRING(@DATE,1,4)



    SELECT @TABLENAME= ' TFM840_CSH_TRN_HIST_ARCH_' + @YEAR

    SELECT @QUERY = ' INSERT INTO ' + @TABLENAME
    +' (DIER_CDE, ACCT_NAM,'
    +' ACCT_NUM, CAS_CAT,'
    +' CAS_GRP, CAS_TXN_CDE,'
    +' CAS_TXN_DESC, CLNT_NAM, '
    +' CLNT_NUM, CLNT_REF_NUM, '
    +' CURNCY_CDE, DR_CR,'
    +' GFT_IND, GFT_REF_NUM,'
    +' INSTR_METH_IND, MANL_IND,'
    +' PAY_RECV_IND, SECR_NAM,'
    +' SECR_NUM, STMNT_DTE,'
    +' SYS_ORIG, TRD_DTE,'
    +' TXN_AMT, TXN_DESC,'
    +' USD_PAY_STMT_CDE,'
    +' VAL_DTE, IMPRT_IND)'
    +' SELECT DIER_CDE, ACCT_NAM,'
    +' ACCT_NUM, CAS_CAT,'
    +' CAS_GRP, CAS_TXN_CDE,'
    +' CAS_TXN_DESC, CLNT_NAM, '
    +' CLNT_NUM, CLNT_REF_NUM, '
    +' CURNCY_CDE, DR_CR, '
    +' GFT_IND, GFT_REF_NUM, '
    +' INSTR_METH_IND, MANL_IND, '
    +' PAY_RECV_IND, SECR_NAM, '
    +' SECR_NUM, STMNT_DTE, '
    +' SYS_ORIG, TRD_DTE, '
    +' TXN_AMT, TXN_DESC, '
    +' USD_PAY_STMT_CDE, '
    +' VAL_DTE, IMPRT_IND '
    +' FROM TFM820_CSH_TRN_HIST'
    +' WHERE STMNT_DTE LIKE '
    +' "' + @DATE + '" ' + '%'


    print @QUERY
    EXEC(@QUERY)
    print ' SUCCESS'

    SELECT @DEL_QUERY = 'DELETE FROM TFM820_CSH_TRN_HIST'
    +' WHERE SUBSTRING(TFM820_CSH_TRN_HIST.STMNT_DTE,1,6)'
    +' BETWEEN '+ ' "' + @YEAR +'01" AND ' +' " '+ @YEAR+'12" '


    --EXEC(@DEL_QUERY)


    EXEC ANNL_ARCHV '200604'

    when I give the above exec command , I am getting the below message .


    Server Message: Number 2747, Severity 16
    Procedure 'ANNL_ARCHV', Line 51:
    Incorrect position specifier in format string of PRINT command.
    (1 row affected)
    (return status = -6)

  2. #2
    Join Date
    Jan 2003
    Location
    Geneva, Switzerland
    Posts
    353
    You need to use
    Code:
    print "%1!", @QUERY
    Michael

  3. #3
    Join Date
    Sep 2005
    Posts
    20
    Thanks a lot , what does that mean .

  4. #4
    Join Date
    Jan 2003
    Location
    Geneva, Switzerland
    Posts
    353
    You can only use a litterall string, so you use a placeholder to print the variable.

    You replace

    print @QUERY

    with

    print "%1!", @QUERY

    and you should be fine.

    Michael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •