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
 Transact-SQL (2000)
 proc probs

Author  Topic 

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2004-09-03 : 05:48:14
I have a very simple procedure but I'm not sure what's wrong with it

Create Procedure dbo.GetNextPID
@NewID int output
as
set @NewID = exec GETNEXTID @IDType = 'p'

I get a syntax error that is something to do with the exec statement.

What I am trying to do is call the sproc called GetNextID, which takes a string parameter (in this case just the letter 'p') and returns an integer. It is that integer that I want to be returned from the sproc above. GetNextID will only return a single integer.

I am working on SQL server 7

thanks in advance

steve



Steve no function beer well without

raymondpeacock
Constraint Violating Yak Guru

367 Posts

Posted - 2004-09-03 : 05:57:47
Try this instead

EXEC @NewID = GETNEXTID @IDType = 'p'


Raymond
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2004-09-03 : 06:13:10
I don't believe that!! Well actually I do, I just don't understand it

Many thanks Raymond

steve

Steve no function beer well without
Go to Top of Page

raymondpeacock
Constraint Violating Yak Guru

367 Posts

Posted - 2004-09-03 : 06:18:33
It's just a syntax thing. I've been caught out like that before, so I know how feel!


Raymond
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2004-09-03 : 06:22:59
I have another one now!!! Clearly not my day again.

I have a dynamic statement stored in a variable @SQLID. If I execute this it will always return either a single value or a null. I want to make use of this in a while statement but again it doesn't work.

what I have is

WHILE EXEC @SQLID IS NOT NULL
...

I've tried a number of variant but again am stuck

Any help would be greatly appreciated

many thanks

steve

Steve no function beer well without
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2004-09-03 : 06:31:32
I'm not sure that you can do that. I think you will need to work around it, by storing the result in a variable, then comparing to the variable in the WHILE statement. Just be sure to exec it into the variable before each pass.

-------
Moo. :)
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2004-09-03 : 06:33:46
OK thanks, I was somehow hoping for something a little more elegant.

Maybe all the weather we are having for the time of year has got to me.

Thanks again

steve

Steve no function beer well without
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2004-09-03 : 06:39:59
Just one thing, have you tried WHILE (EXEC @sqlid) is not null

-------
Moo. :)
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2004-09-03 : 08:33:31
It doesn't seem to like that so I've stuck with your original suggestion which works

many thanks

steve

Steve no function beer well without
Go to Top of Page
   

- Advertisement -