Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts

Sunday, April 17, 2011

SQL Server Databases without Owners

Have you ever come across the following error when running exec sp_helpdb?


Server: Msg 515, Level 16, State 2, Procedure sp_helpdb, Line 53 Cannot insert the value NULL into column '', table ''; column does not allow nulls. INSERT fails. The statement has been terminated.


The next thing to check is whether the following T-SQL code returns any rows


select name from master..sysdatabases where sid is NULL


The result is those databases that are associated with owners who no longer exist (or existed another server elsewhere if the databases were restored from another server).


The solution is simple enough:


exec sp_changedbowner 'sa'


Sometimes, due to orphaning, this can still fail. Just run sp_changedbowner to any valid user. Afterwards, changing it to SA should work too, if you wish.


http://www.bigresource.com/MS_SQL-sp_helpdb-Problem-plz-help-Ruk7t4Q1.html is a good blog on this particular problem.

Saturday, April 16, 2011

Understanding Database Behaviour for Developers

I got home last night from my third Galway visit presenting on SQL Server to it's local IT community. Galway is such pretty and vibrant city and I continue to enjoy the opportunity to come and visit it albeit briefly. Despite arriving after 10pm at night, the city showed no signs of quieting down and it was a pleasure to amble the streets from the train station to the hotel (though doing so with 2 laptops is not so good for the spine). My last visit was also in April two years earlier when I presented on the Accidental DBA for the first time and this proved to be an extremely popular topic ever since. This was my second time presenting "Understanding Database Behaviour for Developers" which was first presented to my own SQL Server Ireland User Group on February 15th 2011. Using the feedback from the first event, I spent the last week tuning the presentation, adding more & clearer examples as T-SQL scripts and removing as much code as possible from the slides. I also tried to improve the story flow which was a bit too disjointed for my liking originally. The changes appear to have worked with many more questions and "what-if" scenarios coming from the audience. They say the presenters should never write code in a presentation but some questions were effectively answered by testing it out together there and then. These new cases have been added to my presentation notes. It was my first time presenting to the local Information Technology Association Galway (aka ITAG) and it's leader, Damien Joyce, was both friendly and extremely helpful. I would be happy to return again. The ITAG event details are found at http://www.itag.ie/Home/tabid/81/ctl/View/mid/475/Event/761/Date/20110415/Start/201104151100/End/201104151230/language/en-IE/Default.aspx My presentation notes can be found at http://cid-56e37aa660df4c78.skydrive.live.com/redir.aspx?page=browse&resid=56E37AA660DF4C78!111&type=6&Bsrc=EMSHHM&Bpub=SN.Notifications