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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Does anyone know why the Sproc crashes

Author  Topic 

Linok
Starting Member

34 Posts

Posted - 2007-10-26 : 16:17:34
I'm trying to find why this generated sproc is failing, but I can't find anything on MSDN about not being about to OUTPUT a GUID. Here's the sproc:

CREATE PROCEDURE [dbo].[Members_Insert]
(
@MemId uniqueidentifier = NEWID() OUTPUT,
@Fname nvarchar(50) = NULL,
@Lname nvarchar(50) = NULL,
@Organization nvarchar(50) = NULL,
@Address1 nvarchar(75) = NULL,
@Address2 nvarchar(75) = NULL,
@City nvarchar(50) = NULL,
@State nvarchar(5) = NULL,
@Country nvarchar(75) = NULL,
@PostalCode nvarchar(15) = NULL,
@Phone nvarchar(15) = NULL,
@Fax nvarchar(15) = NULL,
@Email nvarchar(50) = NULL,
@TimeCreated smalldatetime,
@LastUpdated smalldatetime = NULL,
@IsActive bit = NULL
)
AS
SET NOCOUNT ON

INSERT INTO [Members]
(
[MemId],
[Fname],
[Lname],
[Organization],
[Address1],
[Address2],
[City],
[State],
[Country],
[PostalCode],
[Phone],
[Fax],
[Email],
[TimeCreated],
[LastUpdated],
[IsActive]
)
VALUES
(
@MemId,
@Fname,
@Lname,
@Organization,
@Address1,
@Address2,
@City,
@State,
@Country,
@PostalCode,
@Phone,
@Fax,
@Email,
@TimeCreated,
@LastUpdated,
@IsActive
)

RETURN @@Error


The error I'm getting when trying to create it is:
Msg 102, Level 15, State 1, Procedure Members_Insert, Line 3
Incorrect syntax near '('.
Msg 137, Level 15, State 2, Procedure Members_Insert, Line 45
Must declare the scalar variable "@Fname".


Thanks in advance!

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-10-26 : 16:25:23
This is not legal:


>>@MemId uniqueidentifier = NEWID() OUTPUT,

Just declare it as a uniqueidentifier with a default of NULL:


@MemID uniqueidentifier = NULL OUTPUT,

... and set the value within the stored procedure, before the INSERT.

set @MemID = newid()


- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

Linok
Starting Member

34 Posts

Posted - 2007-10-26 : 16:33:20
Awesome!

I knew it had to be something obvious. :-P

Thanks!
Go to Top of Page

richard75013
Starting Member

19 Posts

Posted - 2007-10-26 : 17:04:45
just as an FYI, your usage of unicode data and GUIDs will absolutly hammer you in the future if this is going to be a database that is expected to perform multi user, many users such as an OLTP databases. If you dont plan on converting the database to any other language then toss all of the unicode data types and loose the uniqueidentifier unless you really have a valid reason to store GLOBABLY UNIQUE DATA. This stuff will hose your average rows per page of data and therefore your I/O and read aheads will gather much less data for the same IO it could otherwise get.

Thanks..Richard
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-26 : 17:12:42
You'll get tired of typing that after the 56,000 time Richard
Go to Top of Page
   

- Advertisement -