Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need JOIN template using SQL Server Templates 2005 / 2008 !

Posted on 2009-04-15
5
Medium Priority
?
228 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 2000 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

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

916 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