Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 change data thru select statement

Author  Topic 

knobi
Starting Member

2 Posts

Posted - 2009-08-13 : 19:09:10
Hello Team! i have a SQL question... not sure if it can be done in SQL but.. here it goes...

TABLE:

FIRST_NAME   LAST_NAME
---------- ---------
John Doe
Mary Jane
Paul
Joe Tribiani


I would like to retrieve all names and last names (no secret so far)... but... i would like to insert ONLY on the result of the SELECT statement a " at the begining and end of each name and last name. The result of the select would be something like this :


FIRST_NAME   LAST_NAME
---------- ---------
"John" "Doe"
"Mary" "Jane"
"Paul" ""
"Joe" "Tribiani"


is it possible ?

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-08-13 : 19:35:37
it's called an UPDATE

UPDATE yourTable
SET firstName = '"' + fisrt_name + '"',
lastName = '"' + last_name + '"'

or if you just want it returned in a SELECT statement:

SELECT '"' + first_name + '"', '"' + last_name + '"'
FROM yourTable
Go to Top of Page

knobi
Starting Member

2 Posts

Posted - 2009-08-13 : 20:50:34
quote:
Originally posted by russell

it's called an UPDATE

UPDATE yourTable
SET firstName = '"' + fisrt_name + '"',
lastName = '"' + last_name + '"'

or if you just want it returned in a SELECT statement:

SELECT '"' + first_name + '"', '"' + last_name + '"'
FROM yourTable





thanks ! could you tell me pls what the + sign means ?
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-08-14 : 00:45:28
it means to concatenate whatever is on either side of the plus sign.

try this: SELECT 'a' + 'b' + 'c' and you'll see it clearly
Go to Top of Page
   

- Advertisement -