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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Assign a column a value

Author  Topic 

u2envy1
Yak Posting Veteran

77 Posts

Posted - 2008-11-27 : 01:18:33
How do I assign a column a value in a select statement ?
select column1, column2, column3 = 'T'
From Table1

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2008-11-27 : 01:28:43
SELECT column1,column2,column3
FROM Table1
WHERE column3 ='T'
Go to Top of Page

u2envy1
Yak Posting Veteran

77 Posts

Posted - 2008-11-27 : 02:38:05
That will bring back column3 with value T.
I want to add a new column that does not exist in the Table to have the Value 'T'
select column1, column2, NewColumn = 'T'
From Table1
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-27 : 02:57:24
quote:
Originally posted by u2envy1

That will bring back column3 with value T.
I want to add a new column that does not exist in the Table to have the Value 'T'
select column1, column2, NewColumn = 'T'
From Table1


Do you get any error with this SELECT?

Madhivanan

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

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-27 : 03:02:43
select column1, column2, 'T' AS NewColumn
From Table1


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-27 : 03:16:46
quote:
Originally posted by u2envy1

That will bring back column3 with value T.
I want to add a new column that does not exist in the Table to have the Value 'T'
select column1, column2, NewColumn = 'T'
From Table1


this works for me anyways
Go to Top of Page

u2envy1
Yak Posting Veteran

77 Posts

Posted - 2008-11-27 : 04:14:06
Thx, perfecto !!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-27 : 04:42:15
quote:
Originally posted by u2envy1

Thx, perfecto !!


Which is perfecto?

Madhivanan

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

- Advertisement -