Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Save a value
Message
 
To
24/11/2006 16:06:13
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01172323
Message ID:
01172386
Views:
11
>but where I can add 1 to the result

Did you test the code?
See that I changed the code to be:
'select @TestMe = MAX(NOTEINDX)+1 from ['+@server+'].['+@base+'].[dbo].[SY03900] '
BUT if you want to add 1:
CREATE PROCEDURE dbo.abc2
@server varchar(20),
@base varchar(20),
AS
DECLARE @pnCampo3 numeric(19,5)
DECLARE @Nextvalue int
DECLARE @cad varchar(1000)
set @pnCampo3 = 0.0
set @cad='select @TestMe = MAX(NOTEINDX) from ['+@server+'].['+@base+'].[dbo].[SY03900] '

SET @Nextvalue = 0
sp_executeSql @cad,'@TestMe int OUTPUT', @TestMe = @Nextvalue OUTPUT
SET @Nextvalue = @Nextvalue + 1
SELECT @Nextvalue
set @pnCampo3=@pnCampo3+1.0
I also don't understand why you put yourself into trouble, why not just made this field to be identity?
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform