Tag Archives: T-SQL

Variable and Assignment enhancements – SQL Server 2008

Variable and assignment enhancements are small plus points in SQL Server 2008. We have around 4 things to discuss under this and they are below. All of these are mostly helpful to developers.

  • Declare Statement
  • Compound Assignment Operators
  • Row Constructors
  • Table Valued Parameter (TVP) Lets discuss on this titles one by one Read more »
VN:F [1.9.17_1161]
Rating: 4.0/5 (1 vote cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)

Return Code Values Documentation for sp_send_dbmail procedure

I saw a question on MSDN forums today about return code values documentation for sp_send_dbmail procedure. Microsoft has not documented these return values to the user because when an error exists in the code the user will get a clear description about the error which is easy to understand hence they have provided only description for 0 (failure) and 1 (success). I’ll provide the list of return values and their description here, I’m sharing this since some of the developers will read this value and they can make use of it to get the reason for failure.

Read more »

VN:F [1.9.17_1161]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.17_1161]
Rating: +3 (from 3 votes)

Disk space (including mounted drive) Check via SQL Server

In my previous article on “Diskspace Check via SQLServer” will find only physical \ logical drives that is attached to the system i.e the drive which you see under my computer. I’ve used this script in one of my client machine and found that this script is not capable to check disk space for mounted drives. Hence I’ve written an WMI script and SQL Script (like version 1) to fetch both physical disk & mounted disk space details. I hope this would help most of the DBA’s to monitor their mounted voulmes where they have hosted their database files. Read more »

VN:F [1.9.17_1161]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 2 votes)

FORCESEEK Hint – SQL Server 2008

New article posted on “Forceseek Hint” in SQL Server 2008. Check it out from the link below.

Forceseek hint is a new addition to SQL Server 2008. It forces the query optimizer to use an Index seek instead of Index scan. Forceseek applies to both clustered and nonclustered index seek operations. It can be specified for any table or view in the FROM clause of a SELECT statement and in the FROM clause of an UPDATE or DELETE statement.

FORCESEEK Hint – SQL Server 2008

VN:F [1.9.17_1161]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)

MERGE Statement – SQL Server 2008

New article posted on Merge statement for SQL Server 2008. You can check the article from the link below.

In earlier versions of SQL Server in order to perform INSERT, UPDATE or DELETE we have to have separate T-SQL statements. With the introduction of SQL Server 2008 we have MERGE statement which helps in simplifying this. It allows us to perform DML operations based on certain JOIN conditions in single statement.

The Merge statement basically has two tables namely source table and destination table. We have to perform a join between them using a certain condition. If the condition matches certain action is performed in the target table. If the condition doesn’t matches some other action is performed and so on.

MERGET Statement – SQL Server 2008

VN:F [1.9.17_1161]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)