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)
 Table alias in select query

Author  Topic 

Jomypgeorge
Starting Member

31 Posts

Posted - 2010-10-28 : 03:21:00
Hi friends,

i have a problem in stored procedure.
in some stored procedures i have to return a dataset with more than one table. By default tables are named as 'table1', 'table2'....

is there any way to give some alias name for these tables in select query?.

Thanks in advance....

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-28 : 03:25:18
Can you give an example of what you mean/trying to do?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Jomypgeorge
Starting Member

31 Posts

Posted - 2010-10-28 : 03:42:10
My stored procedure looks like this

CREATE PROCEDURE spdataset
AS
BEGIN
Select 'name' as [Name], '12' as [Number]

Select 'name' as [Name], 'address' as [Addresss]
END
GO

On executing this sp from front end, first result is placed in 'table1' and second result in 'table2' can i give these results some meaningful names like 'NumberTable' and 'AddressTable' ?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-10-28 : 06:14:43
select * from(Select 'name' as [Name], '12' as [Number]) as NumberTable

select * from (Select 'name' as [Name], 'address' as [Addresss]) as AddressTable

Madhivanan

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

- Advertisement -