Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
String comparisons in where clauses
Message
 
 
To
08/11/2013 18:08:51
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008 R2
Application:
Web
Miscellaneous
Thread ID:
01587602
Message ID:
01587639
Views:
60
MS SQL Server pads shorter string to the length of the longer string with spaces before comparison. The same as VFP does in SQL statements with SET ANSI ON.

>Did I miss something between 2005 and 2008 R2 regarding comparing string values for where clauses and joins?
>
>I seemed to remember when I was learning TSQL coming from VFP that you had to be careful in you remote views and I was always defensively using LIKE instead of = and throwing % around at the end of strings to compare and RTRIM ing just about any CHAR column
>
>Anyway, as I'm converting a bunch of VFP views to a SQL backend I'm finding even though the SQL tables hardly ever use VARCHAR and the data was converting without trimming I can say
>
>WHERE table.cname = ?vp_name and not worry about spaces etc even if vp_name is 'Joe ' and the cname col is char(5) (these may not be the best examples but I am very surprised it seems to behave more like VFP now than it used to.
>
>Am I remembering a problem that never existed or did something change in TSQL?
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform