Category Archives: SQL Server

TSQL: Split String into Multiple Columns With Built-in Function

If you need to create an ad-hoc report and split the data into separate columns, you will find it difficult to search online. Online searches may yield result where you need to create a new user defined function or other tricks those are either time consuming or not possible in production environment. You are really […]

TSQL: Split Full Name into First Name and Last Name Columns

If you need to create an ad-hoc report and split full name into first name and last name, online search will suggest to create a custom user defined function. Sometimes, it is not possible to create an user defined function for single ad-hoc report because you need to follow change control process of your organization […]

Get DATETIME value from msdb.dbo.sysjobhistory

If you ever had to work with SQL Job Agent and find out the details about run time for the job/step, you would find it difficult to convert the INT into DATETIME. Here is the quick solution. To get the start date time, use msdb.dbo.agent_datetime function available in SQL Server 2005 onwards. If you are […]

Stop SQL Server trace using SQL command

Today I started SQL Profiler and paused it. After some time, none of the buttons were enabled. I can neither resume nor stop the trace. Here are the sql commands that I finally found to stop the trace. Get the trace id Stop trace

Change Database Name in SQL Server

SQL Server Enterprise Manager does not let you change your database name once you create it. If you want to change your database name, you may have to manually run the following script to change it. First of all you have to login to SQL Server using osql command line utility. Once you are in, […]