Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Writing It Myself, DWIM, and Expectations

by mpeppler (Vicar)
on Sep 14, 2004 at 05:55 UTC ( #390749=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Writing It Myself, DWIM, and Expectations
in thread Writing It Myself, DWIM, and Expectations

Sybase (and presumably MS-SQL) will silently convert "" to " " as it can't store a zero-length string that is not NULL.

Michael


Comment on Re^3: Writing It Myself, DWIM, and Expectations
Re^4: Writing It Myself, DWIM, and Expectations
by Jenda (Abbot) on Sep 14, 2004 at 23:12 UTC

    I can't check it at this moment, but I don't think any recent MS SQL (that is 7.0 and up) does this for varchars. I'm sure I would notice. It does change an empty string to a string containing the right number of spaces for char(N) columns, but there it can't do anything better. If I still remember this node tomorrow when I am at work and can try things I'll test it and post an update.

    Update: Yep, I was right:

    create table foo (svarchar varchar(10), schar char(10)) insert into foo (svarchar, schar) values ('', '') insert into foo (schar) values ('') select '>' + svarchar + '<', '>' + schar + '<' from foo

    Jenda
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
       -- Rick Osborne

      That is the very reason for varchar. And the curious behavior of SQL-92 is because there is no varchar in SQL-92. So you must define your database with char(x) fields and you get the behavior of char(x). Of course.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://390749]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (14)
As of 2014-09-02 11:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (22 votes), past polls