I'm trying to write a Stored Procedure this is what I have so far
Create procedure sp_Create_order
@P_nafn varchar(50),
@P_fj int,
@P_sótt datetime,
@F_kt varchar(10),
@V_nr int,
@L_id int
as
begin
set nocount on
if exists(
select * from Lotur
where L_id=@L_id and
@P_sótt between L_hefst and L_pfrest
)
INSERT INTO Pantar(P_nafn, P_fj, P_sótt, F_kt, V_nr, L_id)
VALUES (@P_nafn, @P_fj, @P_sótt, @F_kt, @V_nr, @L_id)
end
but I am getting these errors
Msg 102, Level 15, State 1, Procedure sp_Create_order, Line 14 Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Procedure sp_Create_order, Line 15 Incorrect syntax near ' '.
on these lines
select * from Lotur
where L_id=@L_id
and
@P_sótt
, L_hefst
and L_pfrest
are all dates and I am tryng to put a condition on saying that nothing should be Inserted unless @P_sótt
is equal to or between L_hefst
and L_pfrest