Ajiths blog

.Net /SQL for all

Entries for the ‘SQL’ Category

Inserted and deleted tables in SQL2005

Inserted and deleted tables are mainly used inside triggers. But with OUTPUT clause , we can access above virtual tables. That is actually usefull to reduce number of lines when we write quearies. Thanks Aneef for showing me this. I would like to share it with you. Lets try to undestand it using following queary.
/* [...]

Leave a Comment

How to search or replace string from right side

Assume that you have comma separated names list and you want to replace last comma sign by string ‘and’, you can reverse string value and find the char index and do it as below(or download Script).   
DECLARE @StringList varchar(200)
DECLARE @index INT
DECLARE @lastWord varchar(100)
SET @StringList = ‘Aneef,Ajith,Gayan,Manoj,Jude,Julius’
SELECT @index=charindex(’,’, reverse(@StringList))
SELECT @lastWord=right(@StringList,charindex(’,’, reverse(@StringList)) -1)
SELECT SUBSTRING(@StringList,1,LEN(@StringList)-@index)+’ and ‘+@lastWord

Leave a Comment

SQL cumulative calculations without looping

               I have seen several times some people use loops, cursors to do cumulative calculations. But I think we can use following basic way to do calculations without using loops or cursors .Just create sample table (run attached script) and try following SQL
DECLARE @tempValue FLOAT
SET @tempValue=1
UPDATE Sample SET @tempValue=CalculatedValue=(MonthlyValue+1)*@tempValue
SELECT * FROM Sample
Download Script

Comments (1)

Rotation of banner adds using ASP.NET

Today advertisement management is one of major area in web development. So I thought of having blog post about that.
            Following basic features can be seen in a banner management system.
      • Scheduling multiple banners.
            Set start and end time frames
            Set advertisers that cannot appear on the same page(competitors)
            Determine the sequence and timing [...]

Comments (6)

MICROSOFT SQL SERVER 2005 FULL TEXT INDEX

For a catalogue web application I was asked to provide a kind of catalogue search facility. According to the requirement, I had to design search supported for exact / similar matching including Keyword and wildcard with predictive suggestions. To achieve this task I realized that fulltext search is the best way.
In this article we will [...]

Comments (4)

  
Sri Lanka .NET 
                Forum Member