Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CREATE PROCEDURE [dbo].[Insert_User]
@Username NVARCHAR(20),
@Password NVARCHAR(20),
@Email NVARCHAR(30)
AS
BEGIN
SET NOCOUNT ON;
IF EXISTS(SELECT UserId FROM Users WHERE Username = @Username)
BEGIN
SELECT -1 -- Username exists.
END
ELSE IF EXISTS(SELECT UserId FROM Users WHERE Email = @Email)
BEGIN
SELECT -2 -- Email exists.
END
ELSE
BEGIN
INSERT INTO [Users]
([Username]
,[Password]
,[Email]
,[CreatedDate])
VALUES
(@Username
,@Password
,@Email
,GETDATE())

SELECT SCOPE_IDENTITY() -- UserId
END
END


while i was inserting to phpmyadmin it's shows

SQL query:

CREATE PROCEDURE [dbo].[Insert_User]@Username NVARCHAR( 20 ) ,
@Password NVARCHAR( 20 ) ,
@Email NVARCHAR( 30 ) AS BEGIN SET NOCOUNT ON ;


MySQL said: Documentation

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[dbo].[Insert_User]
@Username NVARCHAR(20),
@Password NVARCHAR(20)' at line 1
Posted

I believe you have to define the directionality of the parameters similar to ...
CREATE PROCEDURE [dbo].[Insert_User]
 ( IN Username NVARCHAR(20),
 IN Password NVARCHAR(20),
 IN Email NVARCHAR(30))

Note also the brackets surrounding the list

NB I haven't been able to test this

See also mysql reference[^]
 
Share this answer
 
Remove the semicolon -- this isn't C#.

Good Luck
 
Share this answer
 
Comments
Richard C Bishop 13-Feb-14 13:42pm    
You "solution" has nothing to do with what the OP asked.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900