Sql Server

SQL server provides a good set of functions which will perform the required string operation. But, Many times we use T-SQL to do string operation.

Let us create a User Defined Function which will return all the special characters for the specified string.

--Select dbo.udf_RemoveSpecialChars('sarath#revuri##@gmail.com')
Create FUNCTION dbo.udf_RemoveSpecialChars
	(@strValue VARCHAR(1000))
	DECLARE @intAlpha INT
	SET @intAlpha = PatIndex('%[^A-Za-z0-9@._-]%',  @strValue)
	WHILE @intAlpha > 0
		SET @strValue = STUFF(@strValue, @intAlpha, 1, '' )
		SET @intAlpha = PatIndex('%[^A-Za-z0-9@._-]%',  @strValue )
RETURN ISNULL(@strValue,null)

User Rating: / 20

Alexander Chigrik
This e-mail address is being protected from spambots. You need JavaScript enabled to view it

General Concepts

When you perform any data modification operations (INSERT, UPDATE, or DELETE statements) table fragmentation can occur. When changes are made to the data that affect the index, index fragmentation can occur and the information in the index can get scattered in the database. Fragmented data can cause SQL Server to perform unnecessary data reads, so a queries performance against a heavy fragmented table can be very poor. If you want to determine the level of fragmentation, you can use the DBCC SHOWCONTIG statement. The DBCC SHOWCONTIG statement displays fragmentation information for the data and indexes of the specified table or view.


Performance tuning is not easy and there aren’t any silver bullets, but you can go a surprisingly long way with a few basic guidelines.

In theory, performance tuning is done by a DBA. But in practice, the DBA is not going to have time to scrutinize every change made to a stored procedure. Learning to do basic tuning might save you from reworking code late in the game.


All tools listed are free with no known expiration date. In order to download them, some sites will require you to register which might result in a phone call or e-mail from the vendor. Some tools are free versions of vendor's purchasable software with features disabled. While others tools are on par or better than what you can purchase.


As we work with other Professionals in our industry, we quickly learn that there are many ways to accomplish a given task. When presented with multiple options in a situation, there are times where one option stands out as the optimal choice based upon our general knowledge of the database engine.

There are also times where the optimal choice may not be so obvious and will vary depending on many considerations such as database architecture, level of use, indexing, hardware configuration or general best practices. Any given approach may perform superbly with one database and drag on another.

<< Start < Prev 1 2 Next > End >>
Page 1 of 2