Solved

Need JOIN template using SQL Server Templates 2005 / 2008 !

Posted on 2009-04-15
5
175 Views
Last Modified: 2012-05-06
Hi,

I have two tables T1 (X, Y) & T2 (A, B) :

SQL
====

SELECT T1.X, T2.B
FROM T1 JOIN T2
WHERE T1.X = T2.A

TQL
====

SELECT <Columns, sysname, >
FROM <Parent_Table, sysname, > JOIN <Child_Table, sysname, >
WHERE <Parent_Table, sysname, >.<PrimaryKey, sysname, > = <Child_Table, sysname, ).<ForeignKey, sysname, >

Now I want to have the aliases like this:

SQL
====

SELECT T1.X, T2.B
FROM T1 u JOIN T2  v
WHERE u.X = v.A

Can you please provide me the JOIN template using SQL Server Templates 2005 / 2008 ?

TQL
====

-- Need here

Thanks
0
Comment
Question by:milani_lucie
  • 2
  • 2
5 Comments
 
LVL 22

Expert Comment

by:8080_Diver
ID: 24150321
Try the following:
SELECT T1.X, 

       T2.B

FROM T1 u 

INNER JOIN T2  v

ON    U.X = V.A

Open in new window

0
 

Author Comment

by:milani_lucie
ID: 24150408
I am expecting TQL. Not an SQL Command.

Thanks
0
 
LVL 25

Accepted Solution

by:
reb73 earned 500 total points
ID: 24150435
Like this, perhaps?
SELECT <Columns, sysname, >

FROM <Parent_Table, sysname, > <Parent_Table_Alias, char(1), > 

JOIN <Child_Table, sysname, > <Child_Table_Alias, char(1), >

WHERE <Parent_Table_Alias, char(1), >.<PrimaryKey, sysname, > = <Child_Table_Alias, char(1), >.<ForeignKey, sysname, >

Open in new window

0
 

Author Comment

by:milani_lucie
ID: 24151268
reb73:

This is what i am looking for. BTW: Where i need to use "sysname" and "Other Data Type (Like Char, Varchar, Int etc..)" ? Can you please explain to me in simple terms ?

Thanks
0
 
LVL 25

Expert Comment

by:reb73
ID: 24151323
The second parameter is the datatype for the parameter value.

sysname is a native datatype used to store/reference object identifiers (like table names, view names, procedure names etc)..

Since your alias is not an object name (and I'm presuming that you would tend to use a 1 char alias), I've used char(1).. But you can change this to a datatype/length that's suitable for you (e.g. char(2), varchar(5) etc)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now