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
 Adding a column to the output

Author  Topic 

robp74
Starting Member

5 Posts

Posted - 2008-07-24 : 11:33:13
Hi All,

Forgive me if this question is redundant. I have checked the FAQ and haven't seen what i was looking for. I am very new to SQL, and I'm trying to create a nonexsistent column that displays predetermined info ONLY on the output of the query. i do not want to add this column to the table. As ridiculous as it seems I have not been able to find the command any where. Please help!!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-24 : 11:36:30
you can .just include it in your select list along with other fields.
like select field1,field2,...,'YourValue' FROM Table
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-07-24 : 11:37:07
Select <your old columns>
,[MyNewColumn] = <whatever I want it to>
From
myUnaffectedTable

Jim
Go to Top of Page

robp74
Starting Member

5 Posts

Posted - 2008-07-24 : 11:44:12
Thank you very much! Really appreciate the quick response.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-25 : 03:19:32
quote:
Originally posted by visakh16

you can .just include it in your select list along with other fields.
like select field1,field2,...,'YourValue' FROM Table


and dont forget to include alias name too

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2008-07-25 : 12:00:59
FYI, Per BOL:

The AS clause is the syntax defined in the SQL-92 standard for assigning a name to a result set column. This is the preferred syntax to use in Microsoft SQL Server.

:)
Go to Top of Page
   

- Advertisement -