Bitwise operators  The comparison operators

Chapter 1: SQL Building Blocks

The String concatenation operator

The string operator + can concatenate two or more character or binary expressions. For example:

  1. select Name = (au_lname + ", " + au_fname) 
        from authors
    

    Displays author names under the column heading “Name” in last-name, first-name order, with a comma after the last name; for example, “Bennett, Abraham.”

  2. select "abc" + "" + "def"
    

    Returns the string “abc def”. The empty string is interpreted as a single space in all char, varchar, nchar, nvarchar, and text concatenation, and in varchar insert and assignment statements.

When concatenating non-character, non-binary expressions, use convert:

select "The date is " + 
    convert(varchar(12), getdate()) 




Copyright © 2005. Sybase Inc. All rights reserved. The comparison operators

View this book as PDF