7月 17, 2015

sql 指標的使用方法

declare @p3 nvarchar(4);
DECLARE cs CURSOR FAST_FORWARD for select 單位代碼 from View_LiveUnit where 單位代碼 < 0242;
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
open cs;
FETCH NEXT FROM cs INTO @p3;
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO [HR].[dbo].[HR_UnitDivisionCode]
([單位代碼]
,[科別代碼]
,[生效日期]
,[總分行別]
,[科別名稱]
)
VALUES
(@p3,531,getdate(),0,'作業組'

)
INSERT INTO [HR].[dbo].[HR_UnitDivisionCode]
([單位代碼]
,[科別代碼]
,[生效日期]
,[總分行別]
,[科別名稱]
)
VALUES
(@p3,532,getdate(),0,'業務組'

)
FETCH NEXT FROM cs INTO @p3;
END

CLOSE cs;
DEALLOCATE cs;
END

沒有留言: