Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 getting error while insertion

Author  Topic 

alok.mailbox
Starting Member

2 Posts

Posted - 2008-06-18 : 00:27:14
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


ALTER PROCEDURE [dbo].[usp_World_Ins_data]
-- Add the parameters for the stored procedure here
@UserName nvarchar(50),
@Password nvarchar(15),
@Email nvarchar(100),
@IsChecked bit,
@ReceiveNews bit

AS


BEGIN

SET NOCOUNT ON;

IF EXISTS(SELECT UserName FROM World_Registration WHERE UserName=@UserName)
RAISERROR('Username exists',16,1)
ELSE IF EXISTS(SELECT Email FROM World_Registration WHERE Email=@Email)
RAISERROR('Email exists',16,1)
ELSE
INSERT INTO World_Registration(UserName,Password,Email,IsChecked,ReceiveNews)
VALUES(@UserName,@Password,@Email,@IsChecked,@ReceiveNews)

END


if executed once it works properly like
[usp_World_Ins_data] 'aa','aa','ravinderpal@netbiz.in','1','1'

while if i m trying to execute stored procedure like this three times
i mean more than one time
[usp_World_Ins_data] 'aa','aa','ravinderpal@netbiz.in','1','1'
[usp_World_Ins_data] 'aa','aa','ravinderpal@netbiz.in','1','1'
[usp_World_Ins_data] 'aa','aa','ravinderpal@netbiz.in','1','1'

it gives error:
Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near 'usp_World_Ins_data'.

pls help me

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-18 : 00:50:43
seperate them by GO and try


[usp_World_Ins_data] 'aa','aa','ravinderpal@netbiz.in','1','1'
GO
[usp_World_Ins_data] 'aa','aa','ravinderpal@netbiz.in','1','1'
GO
[usp_World_Ins_data] 'aa','aa','ravinderpal@netbiz.in','1','1'
Go to Top of Page

alok.mailbox
Starting Member

2 Posts

Posted - 2008-06-18 : 00:57:26
thank's visakh16..
but what was happenning behind that error.. can u pls tell me
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-18 : 01:14:20
quote:
Originally posted by alok.mailbox

thank's visakh16..
but what was happenning behind that error.. can u pls tell me


Each sp call should be in seperate batch
Go to Top of Page
   

- Advertisement -