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)
 stored procedure syntax

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-06-12 : 09:18:20
maya writes "SQL 200 Windows NT service pack 6
I need to create stored procedure, that will find highest number in table, increment by one and append new record using that number as ID. The following code worked in query analyzer, but when I want to create it as stored procedure I am getting syntax errors. I appreciate any help.
Here is the code

USE [dbSecurity]
GO
CREATE PROCEDURE [InsertTblAuthorizedPerson]
(@userIDnew [char](10),
@userNameIn [char](60),
@temp1 int,
@temp2 int)
AS
set @temp1=(select top 1 userID from [dbSecurity].[dbo].[tblAuthorizedPerson]
order by userID desc)
set @temp2=(@temp1 + '1')

INSERT INTO [dbSecurity].[dbo].[tblAuthorizedPerson]
([userID],
[userName],
[userValid])

VALUES
( @temp2,
@userNameIn,
'1')"
   

- Advertisement -