As more DBAs across the planet begin using SQL 2005 Tools, but still manage SQL 2000 servers with them, I suspect there will be lots of muffled moaning as to where all the good old features have gone. Although Management Studio has some very nice long-awaited features, some of the good old stuff just isn’t there.
Where are my tried and true tools, such as Taskpad? Where’s the IF EXISTS DROP option when I script out the stored procedures? Can someone pinch me and tell me this is just a bad dream?
The aspirin industry will profit enormously … that sort of thing.
To name a few good old pals that have all but disappeared into obscurity:
- Ability to script permissions quickly on stored procedures.
- Ability to see disk space quickly in database properties.
- Time of creation of stored procedures.
Sure, if you’re connecting to the instance of SQL Server 2005 with Management Studio you have colorful reports and a plethora of professional-looking graphs at your disposal — but what about the majority of us that still have not migrated our servers to SQL 2005 but already upgraded the tools?
The good news is this will tend to convert many GUI DBAs into hardened command-line pros, improve their typing skills, etc. In the next section I will show how you can still take advantage of the old tools’ functionality.
Don’t know about you all, but I really like the Taskpad, and use it all the time. I am as used to it as I am to my old pair of slippers — it fits my needs. And even if it did throw a vague error now and then I forgive it especially since it’s gone forever. But how do we get its functionality back?
The General tab in the Database section is now in database properties under the same heading.
Maintenance section-like information can be found by querying the backupset table in msdb:
select max(backup_start_date) from backupset where database_name = ‘my_db’
Note: Database options, Number of Users, Date Created, and Owner can still be found in database properties in SQL 2005 tools.
Space allocated section information can be found by running this T-SQL:
select * from sysfiles
Or if you just need to find the space used by your log, execute:
DBCC SQLPERF (LOGSPACE)
The Table Info tab? I don’t use this one very often, but you can get similar functionality by running:
Exec sp_spaceused ‘your_table_name’
To Script Multiple Stored Procedures Including Permissions
Right-click the database, choose Tasks > Generate Scripts, and pick your database. Set Include object Level Permissions to True. Note: If you set the Include if NOT EXISTS option to true, the script will not create the stored procedure if it already exists on the target database.
Click Next and select Stored Procedures only. Next, select which procs you want to script, review your final options, and click Finish.
Unfortunately, if you want to drop/recreate the procedures if they exist on the target server, you will need to include the following script manually in the beginning of each procedure:
IF EXISTS (SELECT name FROM sysobjects
WHERE name = ‘your_proc_name’ AND type = ‘P’)
DROP PROCEDURE ‘your_proc_name’
This one is truly beyond me. For reasons known only to Microsoft and the CEO of Bayer (or whoever is the largest headache drug company these days) this option was excluded from the final SQL 2005 RTM.
See Disk Space
If you’re like me, you’re used to clicking on database properties and the ellipsis in order to see the free disk space on the server. In SQL Server 2005 you can get this information in the report, but until then you can run an undocumented extended stored procedure: