Groups | Blog | Home
all groups > sql server programming > july 2004 >

sql server programming : select statment with wrong sytnax


Joe Celko
7/25/2004 11:07:25 AM
1) KEY is a reserved word and too vague to be a column name anyway. I
hoped that was just for the psuedo-code.

2) You need to add a constraint to the unit column so that you do not
get unwanted spaces in it in the first place. Basic data quality rule:
when you find a leak (DML), don't forget to fix the pipe (DDL) after you
mop the floor.

3) There is nothing wrong with a two-column key, so what is the reason
for the concatenation? If you are doing this for display, then that
would be a violation of the tiered architecture. That kind of thing was
done in COBOL a lot because the langauge assumed contigous storage and
it was easy to declare a single field in the file to build a
concatenated field for display.

--CELKO--
===========================
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are.

*** Sent via Developersdex http://www.developersdex.com ***
Eric Sabine
7/25/2004 12:05:04 PM
check out the REPLACE statement in the BOL.

hth
Eric


[quoted text, click to view]

Agnes
7/25/2004 11:34:52 PM
select (sealno + trim(unit) ) as key from myTable
I need to have my key , however, i need remove the space in "unit" field and
i can't use trim..
What should I do , thanks
From agnes

Joe Celko
7/26/2004 7:32:33 AM
TRIM is a Standard SQL function that is missing in T-SQL. For future
reference the synax is:

<trim function> ::=
TRIM <left paren> <trim operands> <right paren>

<trim operands> ::=
[[<trim specification>] [<trim character>] FROM] <trim source>

<trim source> ::= <character value expression>

<trim specification> ::= LEADING | TRAILING | BOTH

<trim character> ::= <character value expression>

--CELKO--
===========================
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are.

*** Sent via Developersdex http://www.developersdex.com ***
Agnes
7/26/2004 6:00:43 PM
how about not 'key'

select (code)+trim(name) as description. from mytable
it return error about "trim"

"Joe Celko" <jcelko212@earthlink.net> ???
news:OApI%23IncEHA.3096@tk2msftngp13.phx.gbl ???...
[quoted text, click to view]

AddThis Social Bookmark Button