السلام عليكم ورحمته الله وبركاته
هو انا عايزاه اعمل الاتى عند حساب المرتبات للموظفين
عايزاه اولا اجيب التاريخ من الجدول بحيث ان لو التاريخ بيساوى تاريخ الى فى الشاشة يجب البيانات الى فى الجدول
ثانى حاجة لو التاريخ مش بيساوية يجيب البيانات الشهر الى فات يعنى تاريخ الشهر -1
انا وصلت للكود دا بس عايز طبعا تصحيح
CREATE PROCEDURE salary
-- Add the parameters for the stored procedure here
@date datetime ,
@date1 datetime ,
@olddate datetime
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
@date1 =SELECT date FROM salary WHERE date=@date
IF @date1=@date
SELECT * FROM salary WHERE date=@date
ELSE
@olddate=SELECT dateadd(MONTH,-1,date)
INSERT INTO salary (@id1,@sal1,@sal2,@sal4,@sal5,@sal6,@sal7,@sal8,@sal9,@sal10,@sal11,@sal12,@sal13,@sal14,@sal15,@sal16,@sal17,@sal18,@sal19,@date ) SELECT @id1,@sal1,@sal2,@sal4,@sal5,@sal6,@sal7,@sal8,@sal9,@sal10,@sal11,@sal12,@sal13,@sal14,@sal15,@sal16,@sal17,@sal18,@sal19 FROM salary WHERE date=@olddate
END
GOبحيت ان @date دا عبارة عن تاريخ الشاشة
@date1 دا تاريخ بجيبه بحيث انى هقارن بين الى موجود فى الجدول والى بيدخله المستخدم
@olddate دا الى هيجيب ليا تاريخ الشهر الى فات
وشكرا
ودا الغلط الى بيظهر
Msg 102, Level 15, State 1, Procedure salary, Line 18
Incorrect syntax near '@date1'.
Msg 102, Level 15, State 1, Procedure salary, Line 22
Incorrect syntax near '@olddate'.
Msg 137, Level 15, State 2, Procedure salary, Line 24
Must declare the scalar variable "@id1".
Msg 137, Level 15, State 2, Procedure salary, Line 24
Must declare the scalar variable "@id1".
