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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Single Space

Author  Topic 

callawayx14
Yak Posting Veteran

73 Posts

Posted - 2012-01-05 : 16:25:34
I'm attempting to find records where a field contains only a single space...not an emty string etc. Any ideas?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-01-05 : 16:27:47
select * from t1 where c1 = ' '

That's single quote, space, single quote.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

callawayx14
Yak Posting Veteran

73 Posts

Posted - 2012-01-05 : 16:35:27
Thank you.
Correct me if I'm mistaken but wont that return records for multiple spaces as well?

Thank you
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-01-05 : 16:41:25
No it won't. It'll only return an exact match of a single space. The equal sign is for exact matches.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

callawayx14
Yak Posting Veteran

73 Posts

Posted - 2012-01-05 : 16:43:02
Thank you very much for your help. I appreciate it :)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-01-05 : 17:02:44
You're welcome, no problem.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -