简体   繁体   中英

How should I pass a formula in stored procedure?

I have a stored procedure that has 1 parameter @MONTH

I want to set this parameter to this formula:

CONVERT(VARCHAR(10),YEAR(GETDATE()))+'0'+CONVERT(VARCHAR(10),MONTH(GETDATE())-2)

so I'll get something like that: @MONTH = 201405 .

How do I set the parameter with the formula?

Thanks.

DECLARE @MONTH int 
SET @MONTH = CONVERT(VARCHAR(10),YEAR(GETDATE()))+'0'+CONVERT(VARCHAR(10),MONTH(GETDATE())-2) 
EXEC YourProcedure @MONTH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM