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 2008 Forums
 Transact-SQL (2008)
 define table as

Author  Topic 

jasmen
Starting Member

11 Posts

Posted - 2014-02-25 : 07:07:08
i have table
i want to define it as letter for example e
so i can write in stored procedure
e.tables columns
example
e.empno

RonnieRahman
Starting Member

6 Posts

Posted - 2014-02-25 : 07:37:33
Hiya

Did you mean Table alias?

Table Alias sample code below:


SELECT
a.column1,
a.column2
FROM myTable a
Where a.column1=1
GROUP BY
a.column1,
a.column2

Go to Top of Page

jasmen
Starting Member

11 Posts

Posted - 2014-02-25 : 07:40:26

i mean like this
select e.empno,e.firstname,e.lastname,e.contactno,p.policyid,p.policyname,p.policyamount,p.companyname
from empregister e inner join policiesonemployees p on e.empno=p.empno where e.designation=@desig
RETURN
e and p are tables
how can define them as e or p
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2014-02-25 : 13:08:27
quote:
Originally posted by jasmen


i mean like this
select e.empno,e.firstname,e.lastname,e.contactno,p.policyid,p.policyname,p.policyamount,p.companyname
from empregister e inner join policiesonemployees p on e.empno=p.empno where e.designation=@desig
RETURN
e and p are tables
how can define them as e or p

You already did. The "proper" way is to use the AS operator:
from empregister AS e inner join policiesonemployees AS p
Go to Top of Page
   

- Advertisement -