|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
problem with synonymsi have a problem when i try to EXEC a stored procedure thru its synonym that is : [exec synonym_to_sp] this only happen when i do that inside another [sp] in another db that is create proc [sp] as exec [synonym_to_sp] go the error i get is : "Procedure or Function 'sp_test' expected parameter '@par', that is not specificated" - - - - - - - - - - - - - - - - - - - - - - - - - - believe it or not, the solution to this error is CREATE SYNONYM <<< without >>> the Server_Name - - - - - - - - - - - - - - - - - - - - - - - - - - is it a bug ?? what is the reason of this behavior ? i gone mad trying to figure out .... -------------------------------------------------------- ---- ---- THIS SCRIPT REPRODUCES THE BEHAVIOR ---- -------------------------------------------------------- -- in db_A use db_A create procedure dbo.sp_test @par varchar(10), @out varchar(10) output as print @par set @out= @par go -- in db_B use db_B create synonym sy_sp_test for db_A.frba.dbo.sp_test -- create synonym sy_sp_test for frba.dbo.sp_test -- uncomment line above for the script WORK FINE go create procedure dbo.sp_test as declare @returned varchar(10) exec sy_sp_test 'hello', @out= @returned output go -- NOW , TEST IT ON DATABASE db_B, let's execute sp_test -- atte, Hernán
Show quote
Hide quote
> -------------------------------------------------------- This script also reproduces the behavior:> ---- > ---- THIS SCRIPT REPRODUCES THE BEHAVIOR > ---- > -------------------------------------------------------- > -- in db_A > use db_A > create procedure dbo.sp_test > @par varchar(10), > @out varchar(10) output > as > print @par > set @out= @par > go > -- in db_B > use db_B > create synonym sy_sp_test for db_A.frba.dbo.sp_test > -- create synonym sy_sp_test for frba.dbo.sp_test > -- uncomment line above for the script WORK FINE > go > create procedure dbo.sp_test > as > declare @returned varchar(10) > exec sy_sp_test 'hello', @out= @returned output > go > > > -- NOW , TEST IT ON DATABASE db_B, let's execute > sp_test use tempdb; go create procedure dbo.sp_test @par varchar(10), @out varchar(10) output as print @par; set @out= @par; go exec dbo.sp_test; go drop procedure dbo.sp_test; go Msg 201, Level 16, State 4, Procedure sp_test, Line 0 Procedure or Function 'sp_test' expects parameter '@par', which was not supplied. Where you call a stored procedure incorrectly doesn't matter if you call it directly or through a synonym. Also note that your syntax is slightly incorrect: exec sy_sp_test 'hello', @out= @returned output If you name one parameter, you must name all parameters. On Wed, 13 Sep 2006 08:57:36 -0400, "Aaron Bertrand [SQL Server MVP]"
<ten.xoc@dnartreb.noraa> wrote: >Also note that your syntax is slightly That is not my understanding, nor my experience. All un-named>incorrect: > >exec sy_sp_test 'hello', @out= @returned output > >If you name one parameter, you must name all parameters. parameters must appear first, and in order without gaps. Named parameters must appear after un-named, and can appear in any order. For an extremely silly example, the stored procedure sp_sproc_columns has five parameters, and this works fine: exec master..sp_sproc_columns 'sp_sproc_columns', @column_name = '@column_name' Roy Harvey Beacon Falls, CT >>exec sy_sp_test 'hello', @out= @returned output Thanks for the correction. I'll amend my statement by changing "must" to >> >>If you name one parameter, you must name all parameters. > > That is not my understanding, nor my experience. All un-named > parameters must appear first, and in order without gaps. "should." I guess I've just been "lucky" that whenever I've forgotten to name a parameter, it wasn't in the correct order or location. A thanks aaron
yes, i know, i forget to name all arguments i named the first argument, as you said : exec sy_sp_test @par= 'hello', @out= @returned output but i still get the error ( and it is still avoided with creating the synonym without "server_name" ) what is wrong ? -- Show quoteHide quoteatte, Hernán "Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> escribió en el mensaje news:u2zZKQz1GHA.968@TK2MSFTNGP03.phx.gbl... | > -------------------------------------------------------- | > ---- | > ---- THIS SCRIPT REPRODUCES THE BEHAVIOR | > ---- | > -------------------------------------------------------- | > -- in db_A | > use db_A | > create procedure dbo.sp_test | > @par varchar(10), | > @out varchar(10) output | > as | > print @par | > set @out= @par | > go | > -- in db_B | > use db_B | > create synonym sy_sp_test for db_A.frba.dbo.sp_test | > -- create synonym sy_sp_test for frba.dbo.sp_test | > -- uncomment line above for the script WORK FINE | > go | > create procedure dbo.sp_test | > as | > declare @returned varchar(10) | > exec sy_sp_test 'hello', @out= @returned output | > go | > | > | > -- NOW , TEST IT ON DATABASE db_B, let's execute | > sp_test | | | | This script also reproduces the behavior: | | use tempdb; | go | create procedure dbo.sp_test | @par varchar(10), | @out varchar(10) output | as | print @par; | set @out= @par; | go | exec dbo.sp_test; | go | drop procedure dbo.sp_test; | go | | Msg 201, Level 16, State 4, Procedure sp_test, Line 0 | Procedure or Function 'sp_test' expects parameter '@par', which was not | supplied. | | Where you call a stored procedure incorrectly doesn't matter if you call it | directly or through a synonym. Also note that your syntax is slightly | incorrect: | | exec sy_sp_test 'hello', @out= @returned output | | If you name one parameter, you must name all parameters. | | I filed a bug here:
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=202754 This is definitely not working as it should. The short-term response will probably be, don't include a local server name. Later, they will either fix it, or make the CREATE SYNONYM statement fail if it uses 4-part naming and the first name is actually the same as the local server name. Until there is a resolution, I suggest that path. Why do you need the local server name in the synonym definition? Show quoteHide quote "bajopalabra" <bajopala***@hotmail.com> wrote in message news:O7lOgcz1GHA.3476@TK2MSFTNGP04.phx.gbl... > thanks aaron > yes, i know, i forget to name all arguments > > i named the first argument, as you said : > > exec sy_sp_test @par= 'hello', @out= @returned output > > but i still get the error > ( and it is still avoided with creating > the synonym without "server_name" ) > > what is wrong ? > > -- > atte, > Hernán > "Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> escribió en el > mensaje news:u2zZKQz1GHA.968@TK2MSFTNGP03.phx.gbl... > | > -------------------------------------------------------- > | > ---- > | > ---- THIS SCRIPT REPRODUCES THE BEHAVIOR > | > ---- > | > -------------------------------------------------------- > | > -- in db_A > | > use db_A > | > create procedure dbo.sp_test > | > @par varchar(10), > | > @out varchar(10) output > | > as > | > print @par > | > set @out= @par > | > go > | > -- in db_B > | > use db_B > | > create synonym sy_sp_test for db_A.frba.dbo.sp_test > | > -- create synonym sy_sp_test for frba.dbo.sp_test > | > -- uncomment line above for the script WORK FINE > | > go > | > create procedure dbo.sp_test > | > as > | > declare @returned varchar(10) > | > exec sy_sp_test 'hello', @out= @returned output > | > go > | > > | > > | > -- NOW , TEST IT ON DATABASE db_B, let's execute > | > sp_test > | > | > | > | This script also reproduces the behavior: > | > | use tempdb; > | go > | create procedure dbo.sp_test > | @par varchar(10), > | @out varchar(10) output > | as > | print @par; > | set @out= @par; > | go > | exec dbo.sp_test; > | go > | drop procedure dbo.sp_test; > | go > | > | Msg 201, Level 16, State 4, Procedure sp_test, Line 0 > | Procedure or Function 'sp_test' expects parameter '@par', which was not > | supplied. > | > | Where you call a stored procedure incorrectly doesn't matter if you call > it > | directly or through a synonym. Also note that your syntax is slightly > | incorrect: > | > | exec sy_sp_test 'hello', @out= @returned output > | > | If you name one parameter, you must name all parameters. > | > | > > actually
i don't need it but gone mad trying to figure out where i had the problem ok let's remove the server name (by now) -- atte, Hernán "Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> escribió en el http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=202754mensaje news:u1PWMnA2GHA.4264@TK2MSFTNGP05.phx.gbl... | I filed a bug here: | | Show quoteHide quote | | This is definitely not working as it should. The short-term response will | probably be, don't include a local server name. Later, they will either fix | it, or make the CREATE SYNONYM statement fail if it uses 4-part naming and | the first name is actually the same as the local server name. | | Until there is a resolution, I suggest that path. Why do you need the local | server name in the synonym definition? | | | | | | | "bajopalabra" <bajopala***@hotmail.com> wrote in message | news:O7lOgcz1GHA.3476@TK2MSFTNGP04.phx.gbl... | > thanks aaron | > yes, i know, i forget to name all arguments | > | > i named the first argument, as you said : | > | > exec sy_sp_test @par= 'hello', @out= @returned output | > | > but i still get the error | > ( and it is still avoided with creating | > the synonym without "server_name" ) | > | > what is wrong ? | > | > -- | > atte, | > Hernán | > "Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> escribió en el | > mensaje news:u2zZKQz1GHA.968@TK2MSFTNGP03.phx.gbl... | > | > -------------------------------------------------------- | > | > ---- | > | > ---- THIS SCRIPT REPRODUCES THE BEHAVIOR | > | > ---- | > | > -------------------------------------------------------- | > | > -- in db_A | > | > use db_A | > | > create procedure dbo.sp_test | > | > @par varchar(10), | > | > @out varchar(10) output | > | > as | > | > print @par | > | > set @out= @par | > | > go | > | > -- in db_B | > | > use db_B | > | > create synonym sy_sp_test for db_A.frba.dbo.sp_test | > | > -- create synonym sy_sp_test for frba.dbo.sp_test | > | > -- uncomment line above for the script WORK FINE | > | > go | > | > create procedure dbo.sp_test | > | > as | > | > declare @returned varchar(10) | > | > exec sy_sp_test 'hello', @out= @returned output | > | > go | > | > | > | > | > | > -- NOW , TEST IT ON DATABASE db_B, let's execute | > | > sp_test | > | | > | | > | | > | This script also reproduces the behavior: | > | | > | use tempdb; | > | go | > | create procedure dbo.sp_test | > | @par varchar(10), | > | @out varchar(10) output | > | as | > | print @par; | > | set @out= @par; | > | go | > | exec dbo.sp_test; | > | go | > | drop procedure dbo.sp_test; | > | go | > | | > | Msg 201, Level 16, State 4, Procedure sp_test, Line 0 | > | Procedure or Function 'sp_test' expects parameter '@par', which was not | > | supplied. | > | | > | Where you call a stored procedure incorrectly doesn't matter if you call | > it | > | directly or through a synonym. Also note that your syntax is slightly | > | incorrect: | > | | > | exec sy_sp_test 'hello', @out= @returned output | > | | > | If you name one parameter, you must name all parameters. | > | | > | | > | > | |
**SORT THE PHYSICAL ORDER ON A TABLE'S COLUMNS**
INSTEAD OF TRIGGERS DO NOT SUPPORT DIRECT RECURSION Explain this please! XP_CMDSHELL Problem SQL 2005 slower than 2000? TABLE FUNCTION Generate intervals Dynamically flattening a table **SET NULL** Trying to do a blog join (entry columns, and # of comments) without success |
|||||||||||||||||||||||