Category Archives: T-SQL

SQL – Query to find data,log,Total Size and other Useful information of all databases – SQL 2000/2005/2008/R2

I’ve encountered a situation where I need to find out the database file,log file, total size and other useful information about a database on SQL Server 2000/2005/2008/R2 versions. The requirement is to use same query and it has to be … Continue reading

Posted in SQL, T-SQL | Tagged , , , | 10 Comments

SQLCMD –Quick Copy of Files – Using Robocopy

The requirement is to move the files to different server programatically and hence I’ve decided to use Robocopy in SQLCMD. Robocopy is a command line utility. It has been available as part of the windows resource kit and It’s one of … Continue reading

Posted in Robocopy, SETVAR, SQLCMD, T-SQL | Tagged , , | 3 Comments

PowerSQL – Different Approaches to Find Free Space in all disk drives

Different ways to find FreeSpace  in all disk drives of a given server T-SQL Using WMIObject Counters All three methods are explained below This post illustrates the simplest way of doing anything with ease using Powershell. I hope everyone agree … Continue reading

Posted in PowerShell, SQL, T-SQL | Tagged , , , , | Leave a comment

SQL- SP_PROCOPTION – AutoNotification to App Owners – When SQL Instance Restarts

We had a situation where Application owners automatically notified whenever server restarts.  The SP_PROCOPTION do have a facility to perform this activity. The SP_PROCOPTION built-in stored procedure being used to invoke the user defined stored proc automatically. The details of this … Continue reading

Posted in SQL, T-SQL | Tagged , , | 4 Comments

The scripting variables can be defined explicitly by using the setvar command or implicitly by using the sqlcmd -v option. Also, this is very helpful in Replication to check rowcount across publisher and subscriber articles. Explicit Call- SQLCMD can be … Continue reading

Posted on by Prashanth Jayaram | Leave a comment

SQL – SQL Server Script to Iterate and Pull Data from All SQL Instances – Database Backup

This Post is a continuation of my previous post. Many times, there is a difficulty in pulling the data to centralized server. As I’ve already mentioned in my previous post PART1,  I’m explaining how to pull the  DATABASE BACKUP information from all listed instance … Continue reading

Posted in SQL, T-SQL | Tagged , , | 2 Comments

SQL – SQL Server Script to Iterate through All SQL Instances – Example Transaction Log Shrinking

There are many ways to execute SQL’s or T-SQL’s across listed SQL Instances. Most of us might have faced and handled this scenario. A script or SQL’s need to be executed across ‘N’ number of instances. This example which does … Continue reading

Posted in SQL, T-SQL | Tagged , , , , | 4 Comments