November 6, 2007 at 1:12 pm
I need to create a stored procedure in the master database (yes, I know it's not that good of an idea). I'm working with SQL 2K5, SP2
Whenever I create it, it is marked as a system stored procedure no matter what I name it.
Any idea why it's happening, and what to do about it?
I'm confused...we've got a couple dozen others in the master database, and have never had this trouble before.
Thanks,
Jason
The Redneck DBA
November 6, 2007 at 1:40 pm
pretty sure this is what happened:
somebody ran this command:
--Turn system object marking on
EXEC master.dbo.sp_MS_upd_sysobj_category 1
after that is run, all commands that create objects in SQL 2000 are system objects. this is fine if you were adding your own stuff, like sp_who3 or something, but you are supposed to turn off system marking after you are done.
to stop that behavior run this command:
--Turn system object marking off
EXEC master.dbo.sp_MS_upd_sysobj_category 2
Lowell
November 6, 2007 at 2:11 pm
Does this apply to SQL 2K5 also?
The Redneck DBA
November 6, 2007 at 3:20 pm
Apparently not...when I tried it in 2K5 it said it doesn't exist. For what it's worth, I also went thru the microsoft support / chat we have access to and they weren't able to provide me with any info on this.
The Redneck DBA
November 7, 2007 at 10:59 am
OK, I've decided to approach this backwards.
Now I'm looking for a way to create a stored procedure (In SQL 2005, NOT 2000) and mark it as a system stored procedure. Hopefully if I can find information on that it will also tell me how to take a system stored procedure and reverse the process. This would be a temporary fix, as I eventually need to figure out why the procedures are getting set to system stored procedures in the first place, but at least it would be something.
Anyone have any ideas?
I know you could mark a user SP as a system SP in 2000, but I don't see anything on it for 2K5.
The Redneck DBA
November 7, 2007 at 12:19 pm
well i found that SQL2005 has a stored proc to mark a specific object as system, instead of an on/off switch, so I'm still looking:
-- SS2k5 provides a stored procedure to mark the object as system
EXEC sys.sp_MS_marksystemobject sp_Yourprocame_That_should_start_with_SpUnderscore
Lowell
November 7, 2007 at 4:33 pm
Thanks.
It's funny. It appears that Microsoft really doesn't want you to create stored procedures as system stored procedures. That proc. you mention isn't in BOL. But all of a sudden their product won't let me create anything but a system stored procedure 🙂
The Redneck DBA
November 8, 2007 at 6:31 am
Jason,
You've got me curious now. How are you seeing it marked as a system stored procedure? In what screen or from what query?
November 8, 2007 at 6:37 am
I'm likewise confused as I make use of placing user procs in master named sp_ and unless I actually mark them as system objects they are not.
Just out of interest I mention that some ( user ) procs named sp_ placed in master that used to be accessible from all user databases in sql 2000 require making into system procs in sql 2005 to do the same thing.
[font="Comic Sans MS"]The GrumpyOldDBA[/font]
www.grumpyolddba.co.uk
http://sqlblogcasts.com/blogs/grumpyolddba/
November 8, 2007 at 6:56 am
I am curious about how you are determining they are system procedures also.
The results returned by the two statements below will NOT return system procedures.
USE MASTER
GO
SELECT * FROM sys.objects WHERE NAME LIKE 'SP_%' AND sys.objects.is_ms_shipped = 0
SELECT * FROM sysobjects WHERE sysobjects.[name] LIKE 'SP_%' and category = 0
November 8, 2007 at 7:37 am
You are correct. Niether of those queries below will return system stored procedures.
I am verifying mine three ways:
1) SELECT * FROM sys.objects where is_ms_shipped = 1
2) SELECT * FROM sys.procedures where is_ms_shipped = 1
3) By looking. There is a special folder for system stored procedures in SSMS
One interesting thing is it's marking that is_ms_shipped flag even if the name doesn't start with sp_. I can name an sp BOB and it gets created as system.
Bob Fazio (11/8/2007)
I am curious about how you are determining they are system procedures also.The results returned by the two statements below will NOT return system procedures.
USE MASTER
GO
SELECT * FROM sys.objects WHERE NAME LIKE 'SP_%' AND sys.objects.is_ms_shipped = 0
SELECT * FROM sysobjects WHERE sysobjects.[name] LIKE 'SP_%' and category = 0
The Redneck DBA
November 8, 2007 at 7:55 am
I take it you're creating these with the CREATE PROCEDURE statement instead of using a template or right-clicking the Stored Procedure folder and choosing new?
November 8, 2007 at 8:00 am
Correct. But all that SSMS does when you right-click and say new is open a new query window with a CREATE PROCEDURE stubbed out for you. Would that really matter?
Brandie Tarvin (11/8/2007)
I take it you're creating these with the CREATE PROCEDURE statement instead of using a template or right-clicking the Stored Procedure folder and choosing new?
The Redneck DBA
November 8, 2007 at 8:02 am
I don't know, but it doesn't hurt to check and see if there is a difference. @=)
I'm going to do some playing around and see if I can replicate what's happening to you now.
November 8, 2007 at 8:08 am
Thanks. I've tried to replicate the issue on other servers (we've got about 15 or so SQL 2K5 boxes) and haven't been able to. There has to be something stupid I'm missing on this one server, but I just can't figure out what it is.
The Redneck DBA
Viewing 15 posts - 1 through 15 (of 23 total)
You must be logged in to reply to this topic. Login to reply