Find the Server Name or Instance Name using T-SQL

The following instructions are supposed to return the same results,  but sometimes the results can be different. The reason is that SERVERPROPERTY automatically reports changes in the network name of the computer, while @@SERVERNAME don’t. SELECT CONVERT(sysname, SERVERPROPERTY(N’servername’)) GO SELECT @@SERVERNAME When they are run on the default instance they return just the server name, but when run over a named instance they return the server name in the following format: servername/instancename.

Read More

Determing SQL Server Table Size within a Database

A common problem that I have recently encountered was trying to identity which table within a database was the biggest one (in record size), therefore, taking up the most physical storage space. I found and modify this store procedure to work with MSSQL 2000, MSSQL 2005, and MSSQL 2008  that will perform all needed data calls and will return a result set with the data on all tables. T-SQL Code:   USE DWDATA GO CREATE PROCEDURE GetAllTableSizes AS /* Obtains spaced used data for ALL user tables in the database */…

Read More