the double pipe

  • In T-SQL, I was almost positive the double pipe ' || ' could be used to merge statements together, like it's done in Oracle or Informix. Am I crazy?

    select "select count(*) from " || name from sys.tables

    The above syntax doesn't work, did I mix the syntax up? Google search is maddening, but did find an article about voting in the double pipe operator. Does anyone else use this?

    ----------------------------------------------------------------------------
    Sacramento SQL Server users group - http://sac.sqlpass.org
    Follow me on Twitter - @SQLDCH
    ----------------------------------------------------------------------------

    Yeah, well...The Dude abides.
  • oracle is double pipe; SQL Server uses the plus sign, and will only concat the char datatypse(char/varchar/nchar/nvarchar); so of you need to concat an integer to the string , you have to explicitly convert it, ie:

    select 'Records found' + convert(varchar,50) + '.'

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply