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)
 Include Literal in Select Results

Author  Topic 

davidshq
Posting Yak Master

119 Posts

Posted - 2010-06-22 : 17:13:48
Lets say I have a database with five columns like this:
ID FirstName LastName Address City
Now I want to query all the rows in this table:
select ID, FirstName, LastName, Address, City from tableName
What if I want to add a static value not contained in a column into the result set - for example "staticState" (in pseudo)
select ID, FirstName, LastName, Address, City, staticState="PA" from tableName
How can I accomplish this?
Dave

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-06-22 : 17:58:57
[code]select ID, FirstName, LastName, Address, City, 'PA' as [staticState] from tableName[/code]
Go to Top of Page
   

- Advertisement -