raghu_grdr


hai ,

This is my Table .

Table

TN963 :- Access Allowed.
TN963 :- Access Allowed.
TN963 :- Access Allowed.
TN964 :- Access Allowed.
TN964 :- Access Allowed.
TN964 :- Access Allowed.
TN963 :- Door Not Allowed! Access Disallowed
TN963 :- Access Allowed.
TN963 :- Access Allowed.

i want to select the values before :- in the above table .

So that my output will be

TN963

TN963

TN963

TN964

TN964

TN964

TN963
TN963

TN963

Cheers,

Raghu.G





Re: selecting the values with criteria ?

Rob Farley


Do you mean "select substring(yourcolumn,1,5) from yourtable"






Re: selecting the values with criteria ?

Rob Farley

Or "select left(yourcolumn,5) from yourtable"






Re: selecting the values with criteria ?

raghu_grdr

Thanks . But the value of the no may differ .

example

TN9633

TN9636

TN9636

TN964g

TN964eeee

TN964w345

TN963ee
TN963ffere

TN963333rfref

Now how to select that






Re: selecting the values with criteria ?

raghu_grdr

hai ,

This is my Table .

Table

TN9633 :- Access Allowed.
TN963 4444:- Access Allowed.
TN96322 :- Access Allowed.
TN964 3:- Access Allowed.
TN964333 :- Access Allowed.
TN964 :- Access Allowed.
TN96322 :- Door Not Allowed! Access Disallowed
TN96344 :- Access Allowed.
TN96332323 :- Access Allowed.

i want to select the values before :- in the above table .

So that my output will be

TN9633

TN963 4444

TN96322

TN9643

TN964333

TN964

TN96322

TN96344

TN96332323

Cheers,

Raghu.G






Re: selecting the values with criteria ?

Jens K. Suessmeyer

Hi,

a sample would be:

DECLARE @Text VARCHAR(100)

DECLARE @Delimiter VARCHAR(50)

SET @Text = 'TN9633 :- Access Allowed.'

SET @Delimiter = ' :-'

SElECT LEFT(@Text,ISNULL(CHARINDEX(@Delimiter,@Text),1)-1)

HTH, Jens K. Suessmeyer.

---
http://www.sqlserver2005.de
---





Re: selecting the values with criteria ?

Rob Farley

Ok, like this then:

select left(yourcolumn, charindex(':-',yourcolumn)-2)

The '-2' means that you get rid of both the colon and the space in front of it.

Rob