FinghtingMiao
asked on
how can I write a sp to copy the new entered data to a colum with the if-else statement?
I have a store procedure need to do:
if column [projected_dop]<> column [cal_projected_dop]
then
set column [new_dop]=[projected_dop]
The prupose is any new data entered by the user at the day time need to be copy to a column [new_cop]
My questions is how to right a store procedure like this ?
if worte it , see attachement, but have error:
how can I write a sp to copy the new entered data to a colum with the if-else statement?
if column [projected_dop]<> column [cal_projected_dop]
then
set column [new_dop]=[projected_dop]
The prupose is any new data entered by the user at the day time need to be copy to a column [new_cop]
My questions is how to right a store procedure like this ?
if worte it , see attachement, but have error:
how can I write a sp to copy the new entered data to a colum with the if-else statement?
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[dbo.tbl_vacancy_database_New_POD]
-- Add the parameters for the stored procedure here
AS
if dbo.tbl_Vacancy_Database.[Projected_DOP]<> dbo.tbl_Vacancy_Database.[cal_Projected_DOP]
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
UPDATE dbo.tbl_Vacancy_Database
SET New_DOP= dbo.tbl_Vacancy_Database.[Projected_DOP]
Exec [dbo].[tbl_vacancy_database_Insert_Records]
UPDATE dbo.tbl_Vacancy_Database
SET Projected_DOP = dbo.tbl_Vacancy_Database.[New_DOP] WHERE dbo.tbl_Vacancy_Database.[New_DOP]IS NOT NULL
END
else
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
--UPDATE dbo.tbl_Vacancy_Database
--SET New_DOP= dbo.tbl_Vacancy_Database.[Projected_DOP]
Exec [dbo].[tbl_vacancy_database_Insert_Records]
--UPDATE dbo.tbl_Vacancy_Database
--SET Projected_DOP = dbo.tbl_Vacancy_Database.[New_DOP] WHERE dbo.tbl_Vacancy_Database.[New_DOP]IS NOT NULL
END
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER