I have created an database file inside my asp.net application. Now from server explorer I tried to write a Stored procedure as follows
CREATE PROCEDURE insertData
(
@ID int,
@Name varchar(50),
@Address varchar(50),
@bit BIT OUTPUT
)
as
begin
declare @oldName as varchar(45)
declare @oldAddress as varchar(45)
set @oldName=(select EmployeeName from Employee where EmployeeName=@Name)
set @oldAddress=(select Address from Employee where Address=@Address)
if(@oldName <> @Name | @oldAddress <> @Address)
insert into Employee(EmpID,EmployeeName,Address)values(@ID,@Name,@Address)
SET @bit = 1
END
But this is giving me an error when I am saving it like Incorrect syntax near <..
There are several things wrong here
Won’t work – maybe try
Of course, this will never be true because of the way the two queries above (which could and should have just been one query assigning both variables) make sure that the variables are always equal.
I.e.:
What can
@oldNamebe, if not equal to@Name? (Okay, it could beNULL, but then<>is the wrong operator to use ifNULLis what you’re checking for)I think that what you wanted to write here was: