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 2000 Forums
 SQL Server Development (2000)
 How to show a fake column in select query

Author  Topic 

reddymade
Posting Yak Master

165 Posts

Posted - 2005-11-07 : 10:58:53
I have the following with union,showing 3 columns is it possible to show a fake column 4th column with hardcoded information in it for the first one says pubs as value in it and for second saying store as a value. column name can be (type)

Because i am planning to bind all the data from the resultset in one datagrid: on the front end the user will know this row belongs to pubs and this belongs to stores like that.

SELECT type(fake column with hardcoded value pubs in it), pub_id, pub_name, city INTO results FROM publishers
UNION
SELECT type(fake column with hardcoded value store in it),stor_id, stor_name, city FROM stores


Thank you very much for the information.

karuna
Aged Yak Warrior

582 Posts

Posted - 2005-11-07 : 11:07:59
How about this?

Select 'pubs' as coltype,pub_id,pub_name,city from publishers
union
select 'store' as coltype,stor_id, stor_name, city FROM stores

Thanks

Karunakaran
Go to Top of Page

nathans
Aged Yak Warrior

938 Posts

Posted - 2005-11-07 : 11:08:20



SELECT 	'pubs' as type, 
pub_id,
pub_name,
city
...


Nathan Skerl
Go to Top of Page

reddymade
Posting Yak Master

165 Posts

Posted - 2005-11-07 : 11:31:37
Thank you very much for the info.
Go to Top of Page
   

- Advertisement -