Displaying posts filed under

TSQL Development

Jun
20
2009

Extracting Account Name and Domain from Email using T-SQL

Storing the list of email subscribers is quite often seen in the web based companies. Once the emails are stored they are segmented based on the customer interests and products they have purchased on the website. In this article I will show the simple step of extracting the Account Name and Domain Name using T-sql. [...]

Jun
16
2009

Who Receives the Email when a SQL SERVER JOB Fails

Here is a script that gives you the list of operators name who receive notifications when a job fails SELECT sysoperators.name AS JobName, sysjobs.name AS OperatorName, sysjobs.enabled, sysoperators.id FROM sysjobs INNER JOIN sysoperators ON sysjobs.notify_email_operator_id = sysoperators.id You need to change the sysjobs.notify_email_operator_id to change the Notifications of the Operator.

Jun
16
2009

Playing with SQL SERVER CACHE

Yesterday Afternoon me and my friend were doing some serious Sql manipulation on some heavy datasets that needs to go inside the Cube.We have written some dynamic SQL statement that is going to insert some 40000 rows into a Control table for a Dimension. Weird Enough my friend accidently closed the Query window and for [...]

Apr
27
2009

Checking the Dependencies in Another Database

I have 20 Databases in my production Server and the tables in some database are used by the Views , functions and procedures of some Other Databases. Now I want to find out the Dependencies of the Tables and their Database Location. I can use the following Dynamic SQL to get the SQL statements and [...]

Apr
27
2009

Splitting Website URL in TSQL

Recently I was involved in a task of splitting the URL’s and generating some reference based on them. I started looking around on google and found this function Split from http://www.otecode.com. This Table Valued function returns a list of substring based on the literal you specify as parameter create function [fn_Split] ( @text varchar(8000) ,@Delimiter [...]

Apr
15
2009

Stored Procedures – Output Parameters

Here is how you create a stored procedures with OutPut Parameter The Execution is as follows

Apr
7
2009

Output of a Procedure in a Table

There are cases when SQL developers want to filter the results of Procedures Output. This requires inserting the results of the procedure in the table. Here is how it can be done In the above example the temp table is created with the same columns as that of the procedure output, the Procedure is executed [...]

Apr
6
2009

sp_depends – Dependencies for Objects

Getting the list of tables and Columns that are embedded in a view ,function or a procedure is simple sp_depends ‘viewName or ProcedureName‘ Documented in MSDN http://msdn.microsoft.com/en-us/library/ms189487.aspx

Apr
6
2009

Null value is eliminated by an aggregate or other SET operation

The Problem occurs when an aggregate function(max,sum,avg..) exists on null values. Trying to get rid of the null values may be the solution but in certain cases..you may need the extra data relying on the null values. So whats the solution? Append set ANSI_WARNINGS OFF on the beginning of the sql statement. When using the [...]

Apr
2
2009

Using Update and Top in Sql server 2008

Sql Server 2008′s new TOP statement could help update the Table in batches Consider the following Example The above code illustrates how the batchUpdate can be done using Top(). The top 100 records are updated depending on the criteria where fullname is null so that the same records dont get updated again