You may need to reverse the order of the parameters provided:
Exec chngservername 87119, ‘blue’
Or you can provide the parameter names when you call the SP:
Exec chngservername @srvname = ‘blue’ , @keyid = 87119
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I’m a bit clueless writing this stored procedure. I want to be able to execute the stored procedure to change the name of any server in my sql_servers table. So I wrote this:
Create proc chngservername
@keyid int, @srvname nvarchar(120)
As
Begin
Update dbo.sql_servers set name = @srvname
Where keyid = @keyid
End
Go
Exec chngservername ‘blue’, 87119
But that gives me an error that it can’t convert an nvarchar to an integer.
What am I doing wrong?
You may need to reverse the order of the parameters provided:
Exec chngservername 87119, ‘blue’
Or you can provide the parameter names when you call the SP:
Exec chngservername @srvname = ‘blue’ , @keyid = 87119
Hi @cipher7836 ,
Welcome to Microsoft Q&A!
You could refer to Guoxiong's answer.
Create proc chngservername
@keyid int, @srvname nvarchar(120)
If you create the procedure with the parameters in above order, you have to provide the value of the parameters in the same order when you execute the procedure which means that provide the 87119
firstly and ‘blue’
secondly.
Best regards,
Melissa
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.