在SQL中设置变量

时间:2018-01-25 10:38:31

标签: sql sql-server-2008 stored-procedures

您好我已经运行了以下SQL程序,但我不知道如何设置变量@AgencyProfileID。

EXEC CreateAgencyPayPeriodsWeekly
@AgencyProfileID,
'2017-02-14',       -- Start date (date of first day of first period to be paid)
'2017-03-27',       -- End Date (date of last day of last period to be paid in this tax year)
'2017-02-28',       -- First payment date
14,                 -- Period length, either 7 or 14 days
0,                  -- Remove existing YTD details (always false)
0,                  -- Remove existing pay periods (always false)
0                   -- Create actual pay periods, set to 0 for Hypo

如果AgencyProfileID为101,我会在第一行和第二行之间放置以下内容吗?

EXEC CreateAgencyPayPeriodsWeekly
set @AgencyProfileID = 101
@AgencyProfileID,

我是SQL的新手并且不想破坏任何东西!

1 个答案:

答案 0 :(得分:0)

你可以做到

declare @AgencyProfileID int = 101

EXEC CreateAgencyPayPeriodsWeekly
@AgencyProfileID,
'2017-02-14',      
'2017-03-27',      
'2017-02-28',      
14,                
0,                 
0,                 
0 

或只是:

EXEC CreateAgencyPayPeriodsWeekly
101,
'2017-02-14',      
'2017-03-27',      
'2017-02-28',      
14,                
0,                 
0,                 
0