Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
String comparisons in where clauses
Message
 
 
À
08/11/2013 18:08:51
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008 R2
Application:
Web
Divers
Thread ID:
01587602
Message ID:
01587639
Vues:
59
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--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform