Monday, February 20, 2012
passing table name as parameter for SP - asap
Hi all,
i have SP where i need to pass the tablename and the date as the
parameter
i started like this
CREATE PROC SP_DEL_STG_TAB
@.TABLE_NAME varchar(50) ,
@.PRESENT_REC_LD_DT DATETIME
AS
EXEC ( 'DELETE FROM '+ @.TABLE_NAME +' WHERE LOAD_DT =' +
@.PRESENT_REC_LD_DT)
GO
when i complied i did not find error but during the execution by passing
the parameters using
EXEC SP_DEL_STG_TAB 'STG_UNSUCCESS_LOGINS', '7/3/2004'
it gives an wiered error
Line 1: Incorrect syntax near '3'.
please help me on this as early as possible i am stuck at this point.
thanks in advance
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!Hi
Use YYYYMMDD format for dates.
"sushma B V" <bv.sushma@.iflexsolutions.com> wrote in message
news:%23msW6xBFFHA.624@.TK2MSFTNGP15.phx.gbl...
>
> Hi all,
> i have SP where i need to pass the tablename and the date as the
> parameter
> i started like this
> CREATE PROC SP_DEL_STG_TAB
> @.TABLE_NAME varchar(50) ,
> @.PRESENT_REC_LD_DT DATETIME
> AS
> EXEC ( 'DELETE FROM '+ @.TABLE_NAME +' WHERE LOAD_DT =' +
> @.PRESENT_REC_LD_DT)
> GO
> when i complied i did not find error but during the execution by passing
> the parameters using
> EXEC SP_DEL_STG_TAB 'STG_UNSUCCESS_LOGINS', '7/3/2004'
> it gives an wiered error
> Line 1: Incorrect syntax near '3'.
> please help me on this as early as possible i am stuck at this point.
> thanks in advance
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!|||Try to use a string variable and build the query, then execute it using exec
command
Babu M K
"sushma B V" <bv.sushma@.iflexsolutions.com> wrote in message
news:%23msW6xBFFHA.624@.TK2MSFTNGP15.phx.gbl...
>
> Hi all,
> i have SP where i need to pass the tablename and the date as the
> parameter
> i started like this
> CREATE PROC SP_DEL_STG_TAB
> @.TABLE_NAME varchar(50) ,
> @.PRESENT_REC_LD_DT DATETIME
> AS
> EXEC ( 'DELETE FROM '+ @.TABLE_NAME +' WHERE LOAD_DT =' +
> @.PRESENT_REC_LD_DT)
> GO
> when i complied i did not find error but during the execution by passing
> the parameters using
> EXEC SP_DEL_STG_TAB 'STG_UNSUCCESS_LOGINS', '7/3/2004'
> it gives an wiered error
> Line 1: Incorrect syntax near '3'.
> please help me on this as early as possible i am stuck at this point.
> thanks in advance
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment