Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a view

Status
Not open for further replies.

sonya9879

Programmer
Jun 18, 2004
147
CA
Hi, i am creating the following view and I was wondering if this is a correct query to have? the query works just fine but i am not sure if it is tune the best way.

Basically i have 4 inner join and one left outer join because i need to show the data when applies in the tableextra. As I said, the query works fine but I need to know if this is a proper query for the view I am creating. Any thoughts will be greatly appreciate it thanks.


select
one.uniqueID as uniqueID,
one.unique_id as unique_id,
rtrim(two.Name) as Name,
rtrim(three.Phone) as Phone,
rtrim(four.de) as de,
rtrim(four.me) as me,
rtrim(five.valss) as valss,
rtrim(five.sss) as sss,
rtrim(five.ppp) as ppp,
rtrim(five.ooo) as ooo,
rtrim(extra.per) as per,
rtrim(extra.loc) as loc,
rtrim(extra.ssc) as ssc,
from
tJPayMailLetters one
inner join tabletwo two on one.unique_id = two.ID
inner join tablethree three on one.b_id = three.ID
inner join tablefour four on one.c_id = four.ID
inner join tablefive five on one.d_id = five.unique_id
left outer join tableextra extra on five.e_id = extra.e_id
 
If all the columns are varchars you can eliminate the RTRIM functions

“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
 
Make sure all those join columns are indexed. The primary key ones are already but the foreign key ones need indexing if you want good performance.

Questions about posting. See faq183-874
Click here to help with Hurricane Relief
 
thanks a lot sqldenis and sqlsister, will follow your recommendation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top