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.
| Author |
Topic |
|
sqlstudentap
Starting Member
1 Post |
Posted - 2009-04-15 : 07:19:52
|
| I have written this procedureand while compiling i have not get any errorsCREATE PROCEDURE loginp1 (@p1 NVARCHAR(50),@p2 nvarchar(20),@p3 int output)AS returnbeginSELECT @p3=count(*)FROM logintbWHERE uname = @p1 and pwd=@p2return @p3print @p3endBut when i executing this pprocedurewith commandexec loginp1 'gopal','1234'i got an errorProcedure or function 'loginp1' expects parameter '@p3', which was not supplied.please let me know how to over come this errorsqlstudent |
|
|
theboyholty
Posting Yak Master
226 Posts |
Posted - 2009-04-15 : 07:28:16
|
| Well firstly you've set up your SP to expect three parameters (i.e. 3 peices of information to work with) : (@p1 NVARCHAR(50),@p2 nvarchar(20),@p3 int output). . and only passed two parameters to it.However, on closer inspection, you don't actually need to pass three parameters as p3 is created and processed within the SP. Therefore remove the ',@p3 int output' from your declaration and you should be okay then.You may need to declare your parameter within the SP actually, something like DECLARE @p3 int should do the trick. |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2009-04-15 : 07:29:18
|
Whatever you are expecting this sp to do it isn't going to do it.OUTPUT paramaters work like this IF OBJECT_ID('dbo.foo') IS NOT NULL DROP PROCEDURE dbo.fooGOCREATE PROCEDURE dbo.foo @a INT , @b INT , @c INT OUTPUTAS BEGIN SET @c = @a + @bENDGODECLARE @a1 INT, @b1 INT, @c1 INTSELECT @a1 = 1, @b1 = 2EXEC dbo.foo @a1, @b1, @c1 OUTPUTSELECT @c1WHERE you pass a variable name as each OUTPUT param.Also -- your RETURN statements abort the stored proc -- they don't do what you think they do.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
svicky9
Posting Yak Master
232 Posts |
Posted - 2009-04-15 : 07:29:20
|
| You need to declare the Output Parameter variable declare @op intexec loginp 'gopal','1234',@op select @ophttp://www.sqlserver007.com |
 |
|
|
theboyholty
Posting Yak Master
226 Posts |
Posted - 2009-04-15 : 07:38:22
|
| On second thoughts, you perhaps should consider doing this in a functin rather than in an SP |
 |
|
|
|
|
|
|
|