Multiple ways to find the name of SQL Server

SQL Server 2005 provides several ways to find the name of the machine or SQL Server instance where you are currently executing your queries. From SQL Server BOL, I have compiled them as follows (Descriptions are copied from SQL Server Books Online)
–Windows computer name on which the server instance is running.
–For a clustered [...]

Retrieving Client PC or Workstation name by TSQL

Auditing tables in enterprise applications stores information about data modification. The best practise in my opinion is to store the relevant information in database my using special Business Layer Auditing functions which make sure that the auditing information is relevant to your business context instead of creating triggers for each table. Triggers put unnecessary load [...]

Visual Studio 2005 Team Edition for Database Professionals

Version controlling of the database code in production environment is not an easy task. Maintaining multiple versions of the database schema, managing different sets of data in production and test environment always gives you hard time. Microsoft has started feeling the importance of this issue and introduced the Visual Studio 2005 Team Edition for database [...]

Writing Cross Tab Queries by PIVOT Operator in SQL Server 2005

Cross Tab Query or Matrix query is one of the classical problem faced by nearly every SQL developer.  There are many ways to approach this problem but each one of them has issues of performance or maintenance or both. This is because they are not native to SQL Server and you need to write complex [...]

Auto Increment value never roll back

Identity column provides you the way to define an auto incrementing ID column which can be later used as a primary key and saves you of writing your own code to generate unique values at every INSERT statement. So far so good, but what happens if I roll back my transaction? Will I be able [...]

SQL Server 2005 Driver for PHP Community Technology Preview (October 2007)

PHP is one of the most popular programming languages for web applications. Mostly PHP applications use mySQL for their database needs. To compete mySQL in PHP market, Microsoft has announced the first Community Technology Preview of  SQL Server 2005 driver for PHP. This driver provided the scalable and reliable API to communicate with SQL Server [...]

Quickest way to copy table from one database to another database

Sometimes we need to quickly copy a table along with its data and structure to another database. There are many ways to do it like using SQL Server Integration Service etc. but if you are looking for the quickest solution for once in a blue moon situation then you can use SELECT INTO statement in [...]

Execute Dynamic SQL String larger than 4000 characters

Although dynamic sql string is almost always prone to SQL Injection attacks but sometimes they are unavoidable. This is particularly in the case when middle tier dynamically creates where clause and send it to database (which is by the way not a good idea but it is there in the market). The problem with the [...]

Displaying Filtered List in Object Explorer of Management Studio

SQL Server Management Studio provides many improvements over classic Enterprise Manager. One of these improvements is the Filter option for Object Explorer. Normally, when you expand a node of Object Explorer, it lists all objects of that type. For example, if you expand Tables node, you will get the list of all tables. If you [...]

5 Years of development experience or Just 1 year of experience repeated 5 times?

Once a upon a time there was a person who applied for a position of software architect. He got the job interview call. During interview he was asked how many years of experience do you have in software industry? Applicant replied, slightly more than 5 years. Interviewer said “But your resume shows that you have [...]