Solved

RE : SQL Server query 2008

Posted on 2013-05-15
2
158 Views
Last Modified: 2013-05-20
Hi,

Database is SQL Server 2008 R2

I have one table named as Merchant having 3 columns
1) id(Auto increment),
2) Merchantid GUID
3) Name Nvarchar(100)

Whenever i do a search through query it never check the space on right as per below query it should not return any result because there is no space in my values. Values Store are like
5DE04B89-0893-40E8-9918-38A66DC256FD
Widget Test Merchant


select * from MERCHANT where
MERCHANTID='5DE04B89-0893-40E8-9918-38A66DC256FD    '
Return correct results

select * from MERCHANT where
MERCHANTID='5DE04B89-0893-40E8-9918-38A66DC256FDtest123 '
Return correct results

select * from MERCHANT where name='Widget Test Merchant      '
Return correct results

Let me know what is the issue or SQL server 2008 behave like that.
0
Comment
Question by:vikalgupta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
lcohan earned 500 total points
ID: 39168300
Yes, since 2008 looks like trailing spaces are ignored in SQL:

"Trailing spaces are ignored in SQL Server 2008"
http://www.codeproject.com/Tips/215593/Trailing-spaces-are-ignored-in-SqlServer-2008

Maybe check ANSI_PADDING settings in your SQL:

http://decipherinfosys.wordpress.com/2007/02/15/ansi_padding-and-trailing-spaces-in-sql-server/
0
 

Author Closing Comment

by:vikalgupta
ID: 39183466
Thanks
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question