SQL Server Image http://www.Oostdam.Info General pictureMicrosoft SQL Server is a great product to work with. Especially from the release of version 2005 and now 2008. For me, it is the standard for all kinds of databases. The Object explorer, Tuning Advisor, the Query Analyser and T-SQL statements work great, and are a joy to work with. When it goes wrong somewhere, it is mostly a syntax error, program(bug) error or a user error that causes the problem. Stable as it is, I can recomment the use of it to anyone. In this articles I like to share with you, some errors and "best practices" that came up during my work several times. So, initially set up was for my own references, now I share it with you. Enjoy these articles!! Due to the fact that a big percentage of visitors of this page are international based, this article is in the english language.


How to determine Database_ID:
This is a common error, often being made. There are a lot of scripts to be found on the internet, and often in scripts the "DB_ID" or "[Database ID]" occurs. Now how do you find this Database ID if you have found a good script example, but is does not work as you use just the Database ID? Here is what you do. Open the SQL Management Studio and create a new manual Query. Type the following.


Use DatabaseName
Select DB_ID() AS [Database ID]
GO


DatabaseName in this case is the real and complete Database name as you can find under the database listing on the leftside.
So replace that with the database ID your looking for, and the ID is at the bottom of your screen in the Query Results.

To determine all database id's at the same time you can use:

select * from sys.databases

This will give you all the database id's from the whole instance.



Printscreen: Not available.


-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Ben OostdamBen Oostdam has been working with Windows systems since 1993. Worked for several companies as a system administrator, and is currently a Senior Support Engineer for Qurius Managed Services in the Netherlands specialized in System Center Solutions.

Disclaimer: The information contained in this website/article is for general information purposes only. The information is provided as is, by Ben Oostdam and while we endeavour to keep the information up to date and correct, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the website or the information, products, services, or related graphics contained on the website for any purpose. Any reliance you place on such information is therefore strictly at your own risk. In no event will we be liable for any loss or damage including without limitation, indirect or consequential loss or damage, or any loss or damage whatsoever arising from loss of data or profits arising out of, or in connection with, the use of this website. Through this website you are sometimes able to link to other websites which are not under my control. I have no control over the nature, content and availability of those sites. The inclusion of any links does not necessarily imply a recommendation or endorse the views expressed within them. Every effort is made to keep the website up and running smoothly. However, I take no responsibility for, and will not be liable for, the website being temporarily unavailable due to technical issues beyond our control. All entries in these articles, are my individual opinion, or from co-writers and they don't necessary reflect the opinion of my employer.





 

Wednesday the 16th, October 2019. All rights reserved.. // Oostdam WebDesign