When I was finding an SQL server command to create a server alias (cf.), a user suggested this piece of code:
use msdb
go
dbo.sp_set_sqlagent_properties @local_host_server=N'Test'
go
I tried开发者_运维知识库 running it and had "Query executed successfully", but the server alias doesn't seem to be created.
What exactly does the code above do?
How do I undo what the code above does?
Don't ever just run commands recommended by some person online without first trying to understand what they do. You can do a few things to understand this stored procedure before running it, e.g.:
EXEC msdb.dbo.sp_helptext 'sp_set_sqlagent_properties';
For all of my machines, local_host_server property is NULL according to:
EXEC msdb.dbo.sp_get_sqlagent_properties;
So to undo this, you might try:
EXEC msdb.dbo.sp_set_sqlagent_properties @local_host_server = NULL;
However it seems like this stored procedure is undocumented, so that is the best I can offer. I would point you to online documentation (which you may also consider searching for yourself the next time someone offers that you run some unrecognized piece of code), but the search will turn up empty. If someone says to run something and your search turns up empty, that is probably even more reason to be hesitant about just running it.
And just as an observation, since it seems like you didn't notice any behavior change, you may be jumping the gun on scolding anyone for "screwing up your computer." If I told you to fix your iPhone by smashing it with a hammer, would I be to blame for that too? Even if there was no damage because you didn't swing hard enough?
Documentation is now available (albeit not very descriptive).
As I understand it, this sproc is for setting up the SQL Server Agent properties. If you right-click on your SQL Server Agent node in SSMS, and then choose properties, and then make some random changes without clicking OK to save those changes, and then you Script Action To New Query Window, you will see that this sproc is used to make those changes.
For example, here are some changes I set up (without clicking OK to actually make them), and then chose Script Action To New Query Window to see what the proposed changes looked like as a script:
EXEC msdb.dbo.sp_set_sqlagent_properties @email_save_in_sent_folder=1,
@databasemail_profile=N'(myservername)',
@use_databasemail=1
GO
精彩评论