PDA

View Full Version : Sql Server Express /substring


sujith
11-29-2006, 06:58 AM
Im MySql
Select substring_index(Description,' ',10)From Agent

Give first 10 words Of Description From the table Agent


What is its Sql Server Equallent

Hope some one can help me

:)

sujith
11-30-2006, 08:28 AM
What I mean is
I want to get the fuction (in SQlServer Express)
for Extracting some words from a Long string

sujith

Roelf
12-01-2006, 10:13 AM
SQL server does not have an equivalent for that. It cannot determine where wordboundaries are. The best you can do is use the LEFT(string, num) or the SUBSTRING(string, start, end) functions. They work on characters, take the first num characters from the start of the string (LEFT function), or take the characters from the string between the specified start and end number (SUBSTRING function)

Otherwise you have to create a custom function which looks for wordboundaries and extracts the number of words you want.