Browse by Tags

All Tags » T-sql (RSS)

Moved my blog

For all those reading my blog, for your information, I have moved my blog to https://exploresql.com/ Thanks to Simon for his support at sqlblogcasts.com
Posted by Madhivanan | with no comments
Filed under: ,

Find alternate week day

My co-worker had a task of finding minimum alternate week day as of today for a given date and day Consider these data Date : 2009-12-22 day : 5 (it denotes Thursday) It means the event was scheduled on 2009-12-22 which should run on every alternate Thursday...
Posted by Madhivanan | with no comments
Filed under: , ,

Replace data of one table with data of other table

One of the questions asked in a forum was about replacing data of one table by the data of another table The solution that the questioner used was having cursor by looping through the source table and replace particular words by other words from another...
Posted by Madhivanan | with no comments
Filed under: , ,

Happy Holidays

In the Query Analyser, set the Result mode to Text (Press CTRL+T) and run the following code set nocount on select space ( 17 - len ( replicate ( char ( 94 ), no )))+ replicate ( char ( 94 ), no * 2 - 1 ) from ( select top 10 row_number () over ( order...
Posted by Madhivanan | with no comments

Search a value in character column of all tables

Sometimes, you may need to find a value in the characters columns (char, varchar, etc) in all the tables This is one of the methods to do it declare @sql varchar ( max ), @search varchar ( 100 ) set @sql = '' set @search = 'your search string'...
Posted by Madhivanan | with no comments

Removing unwanted characters - Part 2

In my previous post about Removing unwanted characters , I posted a method that used a function Here is another method that uses Dynamic SQL declare @data table ( data varchar ( 100 )) -- table that has source data insert @data select 'tes^@&t...
Posted by Madhivanan | 2 comment(s)
Filed under: , ,

Parsing a string

Now-a-days lot of questions are asked in the forum about extracting particular text from a string Here I give some examples on how to do it --Example 1 (Extracting tags and other informations) declare @s varchar ( 100 ) declare @temp table ( id int identity...

Usage of Semicolons in SQL Server

As you know, semicolon is used as a statement terminator in almost all RDBMSs. However the usage of semicolon is optional in SQL Server except a few cases. Here are atleast the three cases where usage of semicolon is a must 1 At the start of the Common...
Posted by Madhivanan | 2 comment(s)
Filed under: , ,

SQL Server 2008 features that work only in Enterprise Edition

One of the new features available in SQL Server 2008 is compressed backup which takes backup of a database with mimimum possible size. The syntax is backup database db_name to disk = 'backup_path' with init , compression But this works only in...
Posted by Madhivanan | with no comments

Script out Procedures to seperate files

In this post script-out-procedures-and-functions-part-2 , I showed how to script out the procedures in a single file Here is another way to do the same but different file for each procedure. The file name will be the name of the procedure. declare @sps...
More Posts Next page »