Feeds:
Posts
Comments

Archive for the ‘SQL String’ Category

I love reader’s contribution this blog as that brings variety in articles. I encourage my readers to provide their contribution and I will publish then with their name.
Blog Reader Ashish Jain has posted very simple script which will remove duplicate entry from comma delimited string. User Defined Function has very simple logic behind it. It [...]

Read Full Post »

SQL is great with String operations. Many times, I use T-SQL to do my string operation. Let us see User Defined Function, which I wrote few days ago, which will return only Numeric values from AlphaNumeric values.
CREATE FUNCTION dbo.udf_GetNumeric
(@strAlphaNumeric VARCHAR(256))
RETURNS VARCHAR(256)
AS
BEGIN
DECLARE @intAlpha INT
SET @intAlpha = PATINDEX(‘%[^0-9]%’, @strAlphaNumeric)
BEGIN
WHILE @intAlpha > 0
BEGIN
SET @strAlphaNumeric = STUFF(@strAlphaNumeric, @intAlpha, 1, ” )
SET [...]

Read Full Post »

After reading my article SQL SERVER – 2008 – TRIM() Function – User Defined Function, I have received email and comments where user are asking if it is possible to remove trailing spaces, leading spaces, white space, tabs, carriage returns, line feeds etc.
I found following script posted by Russ and Erik. It is modified a [...]

Read Full Post »

Follow up of my previous article of Remove Duplicate Chars From String here is another great article written by Madhivanan where similar solution is suggested with alternate method of Number table approach. Check out Remove duplicate characters from a string
Reference : Pinal Dave (http://blog.SQLAuthority.com)

Read Full Post »

Just a day ago I received phone call from my friend in Bangalore. He asked me
What do I think of storing images in database and what kind of datatype he should use?
I have very strong opinion about this issue.
I suggest to store the location of the images in the database using VARCHAR datatype instead of [...]

Read Full Post »

Few days ago, I received following wonderful UDF from one of this blog reader. This UDF is written for specific purpose of removing duplicate chars string from one large string. Virendra Chauhan, author of this UDF is working as DBA in Lutheran Health Network.
CREATE FUNCTION dbo.REMOVE_DUPLICATE_INSTR
(@datalen_tocheck INT,@string VARCHAR(255))
RETURNS VARCHAR(255)
AS
BEGIN
DECLARE @str VARCHAR(255)
DECLARE @count INT
DECLARE @start INT
DECLARE [...]

Read Full Post »

Following function return all the available collation of SQL Server 2005. My previous article about the SQL SERVER – 2005 Collation Explanation and Translation.
SELECT *
FROM sys.fn_HelpCollations()
Result Set: (only few of 1011 records)
Name [...]

Read Full Post »

Error:
Server: Msg 131, Level 15, State 3, Line 1 The size () given to the type ‘varchar’ exceeds the maximum allowed for any data type (8000)

When the the length is specified in declaring a VARCHAR variable or column, the maximum length allowed is still 8000.
Fix/WorkAround/Solution: Use either VARCHAR(8000) or VARCHAR(MAX) . VARCHAR(MAX) of SQL [...]

Read Full Post »

I came across this SQL String Function few days ago while searching for Database Replication. This is T-SQL Function and it repeats the string/character expression N number of times specified in the function.
SELECT REPLICATE( ‘ http://www.SQLAuthority.com ‘ , 9 )
This repeats the string http://www.SQLAuthority.com to 9 times in result window. I think it is fun [...]

Read Full Post »

In SQL Server 2000 and SQL Server 2005 a table can have a maximum of 8060 bytes per row. One of my fellow DBA said believed that SQL Server 2000 had that restriction but SQL Server 2005 does not have that restriction and it can have row of 2GB. I totally agreed with me but [...]

Read Full Post »

Older Posts »