Tuesday, April 2, 2013

Sql query For Existing

Insert Into Employee (Role_ID, FirstName, LastName, DateOfBirth, Active)
Select @Role_ID, @FirstName, @LastName, @DateOfBirth, @Active
Where not exists (
select 1 from Employee where FirstName = @FirstName
and LastName = @LastName
and DateOfBirth = @DateOfBirth
)

If @@rowcount=0 select 'User already exists!'

No comments:

Post a Comment

Opps Part 1 : Abstraction

  Abstraction in C# is a fundamental concept of object-oriented programming (OOP) that allows developers t...