Showing posts with label Database. Show all posts
Showing posts with label Database. Show all posts

Monday, July 30, 2012

Viewing the disk space usage (size) of all the tables in a SQL Server 2005/2008 database

I spent a couple of hours searching for a script that returns the size of all the tables in a database. Most of the ones that you find use sp_msforeachtable but that is just for one table and you then need to use temporary tables to hold the values.

This article on the Database Journal by Ananth Kumar (AKA MAK) had this handy script that simply works by copy-pasting it as is. Read the linked article for details on viewing the size by schema.

Wednesday, November 2, 2011

Setting up Database Mail for SQL 2005

Problem
Many things have changed with SQL Server 2005 and one of these changes is the replacement of SQL Mail with Database Mail.  This is a good thing, because SQL Mail relied on having a MAPI mail client installed such as Outlook in order for it to work.  With SQL Server 2005, this has changed and now the mail services use an SMTP server to send out emails which makes it a whole lot easier to setup and maintain.  So how do you setup Database Mail?

How to setup SQL Server alerts and email operator notifications in SQL 2005


Database Mail
First setup database mail with a profile named SQLAlerts. The profile can be named anything but in these instructions, the profile name SQLAlerts is referenced. If you wish to use a different profile name just substitute accordingly. For procedures in setting up database mail,see the post.

How to resolve : Agent XPs disabled

You may have seen this sentence in front of your SQL Server Agent in SSMS. and so you can’t start your SQL Server Agent ( maybe only with Network Service account )
You can enable Agent Xp’s in sql server 2005.  I think you’d better first create a Login and give proper roles to the user who run this service ( in my case Network Service with sysadmin role ). Then  run the below query in management studio to enable agent xp’s.

Tuesday, November 1, 2011

What SQL Server service pack & sort order do I have installed ?

If you've used SQL Server for a while,for checking Sort Order sp_helpsort and for summery of SQL servers config sp_server_info for service pack information you're probably familiar with the @@version function. run select @@version in Query Analyzer. Selecting the function in a query window produces the following results on my system. 

Wednesday, September 21, 2011

Sending Automated Job Email Notifications in SQL Server 2000 with SMTP


When you have automated backup jobs running on your database server, sometimes you forget that they are even running. Then you forget to check to see if they are running successfully, and don’t realize until your database crashes and you can’t restore it since you don’t have a current backup.
That’s where email notifications come in, so you can see the job status every morning when you are sipping your coffee and pretending you are working.
SQL Server provides a built-in method of sending emails, but unfortunately it requires you to have Outlook and a profile installed on the server, which isn’t necessarily the ideal way to send an email. Thankfully there is another method, that involves installing a stored procedure on your server that will allow you to send email via SMTP.