我有一个存储过程,它有两个参数:周,年。当我执行存储过程时,它会询问周和年,并且在给出这些值后,它会显示某些结果。现在,我想做的是,我希望将2014年第一周的结果发布到本周。
This is my code,
USE [MyDatabase]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[MySP]
@Week int,
@Year int
AS
BEGIN
exec (Another Stored Procedure from another database)
END
那么,我怎样才能做到这一点?
答案 0 :(得分:0)
T-SQL有一个while
语句可以使用:
declare @current_week int = datepart(week, getdate())
while @week <= @current_week
begin
... do stuff ...
set @week = @week + 1
end