Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Column value with %

Author  Topic 

Dipu710646
Starting Member

10 Posts

Posted - 2010-11-26 : 03:15:22

Hi All,

I have a column called EmpName.

It contains employee name.

It got some values with % .

1 Sana123 1 2000 2010-05-05 00:00:00.000
2 Sana%123 2 3000 2010-05-05 00:00:00.000
3 Sana%123 3 4000 2010-05-05 00:00:00.000
4 Sana%123 3 1000 2010-05-05 00:00:00.000

I want to fetch these records from table.

How will I do that.

Please reply..





Dipankar Sana

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-11-26 : 03:36:29
select * from table where EmpName like '%[%]%'


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-11-26 : 03:41:01
[code]DECLARE @table table (
name varchar(200)
)
insert into @table
select 'Sana%123' UNION ALL SELECT 'Sana123'

select * from @table where charindex(CHAR(ASCII('%')), name) > 0[/code]

- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-11-26 : 04:21:43
select *
from tbl
where EmpName like '%/%%' escape '/'

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-11-26 : 04:37:08
select * from tbl
where len(Empname) <> len(replace(Empname,'%',''))


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-11-26 : 10:41:48
quote:
Originally posted by Lumbago

DECLARE @table table (
name varchar(200)
)
insert into @table
select 'Sana%123' UNION ALL SELECT 'Sana123'

select * from @table where charindex(CHAR(ASCII('%')), name) > 0


- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com



It is as simple as


select * from @table where charindex('%', name) > 0

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -