Friday, June 17, 2011

Important Query For DBA

Which protocol is being used for client-server connectivity in SQL Server?
SELECT net_transport FROM sys.dm_exec_connections WHERE session_id = @@SPID;
Above  query return our server  connection protocol. There are 4 protocol there for connect database server with client.
  • Shared Memory
  • TCP/IP
  • Named Pipes
  • VIA (Virtual Interface Adapter)
Result :

Important Query 1 : Client-server connectivity in SQL Server
Important Query : Client-server connectivity in SQL Server

Determine Free Disk Space in SQL Server with T-SQL Code

select a.FILEID, [FILE_SIZE_MB] = convert(decimal(12,2),round(a.size/128.000,2)), [SPACE_USED_MB] = convert(decimal(12,2), round(fileproperty(a.name,'SpaceUsed')/128.000,2)), [FREE_SPACE_MB] = convert(decimal(12,2), round((a.size-fileproperty(a.name,'SpaceUsed')) /128.000,2)) , NAME = left(a.NAME,15), FILENAME = left(a.FILENAME,30) from dbo.sysfiles a;

Above query will give us status of free space available in datafile. So we can manage sufficient space for database.

Result :

Determine Free Disk Space in SQL Server with T-SQL Code
Determine Free Disk Space in SQL Server with T-SQL Code

No comments:

Post a Comment