SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Stored Procedure Error MSG 15007


Stored Procedure Error MSG 15007

Author
Message
mail4bbt
mail4bbt
Valued Member
Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)

Group: General Forum Members
Points: 52 Visits: 83
Msg 15007, Level 16, State 1, Procedure sp_defaultdb, Line 41
'@LoginString' is not a valid login or you do not have permission.





Here is the procedure



CREATE Procedure [dbo].[SetDefaultDatabase] 

@LoginString NVARCHAR(50),
@DatabaseString NVARCHAR(50)
As

Begin

Set NoCount On

Exec sp_defaultdb @loginame='@LoginString', @defdb='@DatabaseString'

End



GO



Why would this be generating the message

Here is the return

DECLARE   @return_value int

EXEC @return_value = [dbo].[SetDefaultDatabase]
@LoginString = N'Sample\login',
@DatabaseString = N'ABC'

SELECT 'Return Value' = @return_value

GO


Robert klimes
Robert klimes
SSCertifiable
SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)

Group: General Forum Members
Points: 5123 Visits: 3468
try taking the single quotes away from around your parameters

CREATE Procedure [dbo].[SetDefaultDatabase] 

@LoginString NVARCHAR(50),
@DatabaseString NVARCHAR(50)
As

Begin

Set NoCount On

Exec sp_defaultdb @loginame=@LoginString, @defdb=@DatabaseString

End



GO



Bob
-----------------------------------------------------------------------------
How to post to get the best help
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)

Group: General Forum Members
Points: 96669 Visits: 38988
This maybe?



CREATE Procedure [dbo].[SetDefaultDatabase]

@LoginString NVARCHAR(50),
@DatabaseString NVARCHAR(50)
As

Begin

Set NoCount On

Exec sp_defaultdb @loginame = @LoginString, @defdb = @DatabaseString

End

GO




Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
mail4bbt
mail4bbt
Valued Member
Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)

Group: General Forum Members
Points: 52 Visits: 83
So when I use SSMS to exexute the procedure and I enter the Login it puts a single ' in front of the Sample/abc when I go to enter the second parameter for the database. So it looks like 'Sample\login; it works if I go back up and manually change it! How can I keep out the single ' before the string?
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)

Group: General Forum Members
Points: 96669 Visits: 38988
This is how it should be executed:

exec dbo.SetDefaultDatabase @LoginString = '[Sample/abc]', @DatabaseString = 'ThisDatabase';

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search