I have a table in SQL Server with 3 columns Id
(int identity
), email
(nvarchar(50)
), password
(nvarchar(50)
). Now I want to write a query where I can insert email
and password
and that time, I want to return the identity element for id
.
For e.g I insert abc@dal.ca
and password then the identity element value should be returned.
I wrote it as:
@email nvarchar(50), @password nvarchar(50), @id int
insert into addEmail(email, password)
values(@email,@password)
return @id
Is this proper ?? How should I do ? How should I check whether this is working properly or not ? If I select
dbo.sp_addEmailReturnId abc@dal.ca, demo
and click on execute, it shows
Incorrect syntax near '.'.
I am unable to find the error. I am just trying to insert email id and password so that could be inserted and i would get the identity element which is automatically incremented by 1 with every new row.
In code part for asp.net, how would I retrieve the id. ?