" Live as if you were to die tomorrow. Learn as if you were to live forever.. "
- Mahatma Gandhi

Did I Really Write Such A Complex Query?

Posted on November 24th, 2015 by Sathyan R

Why would the Error The query processor ran out of stack space during query optimization. Please simplify the query come? Hi Everyone!   I wanted to share a funny and a tricky experience we had a few days back, we wrote a simple query, to delete certain records from a table. So the Query read […]

How to INSERT, UPDATE or DELETE record in one statement

Posted on November 24th, 2015 by Monalisa Pradhan

Generally we write separate statements to INSERT, UPDATE or DELETE data based on certain conditions. But now in SQL Server 2008 there is a new feature present called MERGE statement using which we can INSERT, UPDATE or DELETE record in one statement. MERGE is a new feature which Microsoft has introduced with SQL Server 2008 […]

New Line character and Forming a comma Separated String in SQL Server

Posted on November 24th, 2015 by Monalisa Pradhan

New Line character in SQL Server Generally we use ‘\n’ as new line character. If we write the same in SQL server Query Analyzer it won’t work. Different operating systems have a different way of understanding new line. Mac only understands ‘\r’ as new line, while Unix and Linux understand ‘\n’ as new line character. […]

Selecting records from more than One Database Using Single Query

Posted on November 24th, 2015 by Monalisa Pradhan

Suppose there is requirement for selecting records from more than one Database. Let’s say, you have different databases for different branch (say: BRANCH1_DB, BRANCH2_DB, BRANCH3_DB). For getting all employees name write the following query: SELECT (FIRST_NAME + ‘  ‘ + LAST_NAME) AS EMPLOYEE_NAME FROM BRANCH1_DB.dbo.EMPLOYEE_INFO UNION ALL SELECT (FIRST_NAME + ‘  ‘ + LAST_NAME) AS […]

GO (Transact-SQL)

Posted on November 24th, 2015 by Subhashish Chaki

GO is the default batch separator keyword for T-SQL. It signals the end of a batch of Transact-SQL statements to the SQL Server utilities. Actually, GO is not a Transact-SQL statement. It is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code editor. The SQL Server utilities interpret GO […]