Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 exec sproc with dynamic paramater

Author  Topic 

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2010-06-14 : 20:33:18
Greetings

Hope you are enjoying world cup as I am! Here is a question I am unable to sort out

exec usp_mypsor @DateTT = dateadd(dd,datediff(dd,0,GETDATE()),-3). I get Incorrect syntax near 'dd'. Have not been getting enought sleep waking up 4am to watch world cup, been staring at screen too long.

Thanks


<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-06-14 : 20:35:24
You need to put that into a variable first and then pass it to the stored procedure.

DECLARE @d datetime

SET @d = dateadd(dd,datediff(dd,0,GETDATE()),-3)

exec usp_mypsor @DateTT = @d

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2010-06-14 : 20:37:16
thanks! so there is no way to do it straight in one line? :(

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-06-15 : 02:54:32
quote:
Originally posted by yosiasz

thanks! so there is no way to do it straight in one line? :(

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion


No, you cant pass getdate() directly as a parameter to a procedure

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -