Solved

Need JOIN template using SQL Server Templates 2005 / 2008 !

Posted on 2009-04-15
5
185 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

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: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 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

21 Experts available now in Live!

Get 1:1 Help Now