473,378 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

sql dinamic

hi

I need generate dinamic sql:
I need a select sentence with all fields of one table 't1'
and all fields of tables which 't1' have foreings keys 't1 ( reflexive ) ,t2,t3,...'

Now, l have de select part, de select from...
but I don`t know how create de join clauses ?

Some idea about this ?

Thank very much.
RaulGZ.
Jul 20 '05 #1
4 2137
raulgz (ra****@ozu.es) writes:
I need generate dinamic sql: I need a select sentence with all fields of
one table 't1' and all fields of tables which 't1' have foreings keys
't1 ( reflexive ) ,t2,t3,...'

Now, l have de select part, de select from...
but I don`t know how create de join clauses ?


Well, the JOIN clause might depend on the logic you want to implement,
so without information, this is a little difficult to guess.

But assuming that you want join FKs to PKs, the key table for you to use
is sysforiegn keys. Here is a an example on how retrieving the data:

SELECT fkcol = col_name(fkeyid, fkey),
parent_table = object_name(rkeyid),
pk_col = col_name (rkeyid, rkey),
keyno,
fkname = object_name(constid)
FROM sysforeignkeys
WHERE fkeyid = object_id('Orders')
ORDER BY parent_table, fkname, keyno

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
Raul,

I'm not sure what you're asking. If you simply want to join
multiple tables, here's an example:

SELECT A.*,C.*,O.* FROM
Accounts A JOIN Customers C ON A.CustID=C.CustID
JOIN Orders O ON O.AcctID=A.AcctID
WHERE C.Name LIKE 'SMITH%'

If that's not the answer you need, please try to clarify the
problem...

Thanks,
Les Matheson
Integral Concepts, Inc,
http://www.ivsds.com

ra****@ozu.es (raulgz) wrote in message news:<9b*************************@posting.google.c om>...
hi

I need generate dinamic sql:
I need a select sentence with all fields of one table 't1'
and all fields of tables which 't1' have foreings keys 't1 ( reflexive ) ,t2,t3,...'

Now, l have de select part, de select from...
but I don`t know how create de join clauses ?

Some idea about this ?

Thank very much.
RaulGZ.

Jul 20 '05 #3


Hi Erland:

Thank very much for your solution.
You really save me. This is what I was looking for.

Thanks again,

R.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4


Hi Les:

Thank you very much, but i need work with sql server
catalog tables. This is a good solution:

SELECT fkcol = col_name(fkeyid, fkey),
parent_table = object_name(rkeyid),
pk_col = col_name (rkeyid, rkey),
keyno,
fkname = object_name(constid)
FROM sysforeignkeys
WHERE fkeyid = object_id('RTCM.PERMISO')
ORDER BY parent_table, fkname, keyno;

Thank again.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marcos Rodríguez | last post by:
Hello all, I have received a dll from a reseller who sold me a data acquisition equipment and I am trying to use functions from the dll file but I am receiving an uncontrolled exception. ...
1
by: dddddd | last post by:
i need do create simple dinamic site - built mainly of pictures(they are the only dinamic part). pictuers differ by the -Location- and by -Time- (in which they were taken)... so on the index...
0
by: Midgar | last post by:
Hi, I have a problem with vb.net : I create dinamically labels in a panel with this code (simplified): panel1.controls.clear dim a as new label a.text="Test" panel1.controls.add(a) I have 6...
3
by: Jose Garcia | last post by:
Hi there, Can somebody explain me how can i use matrixes with dinamic memory? I use malloc and free (NOT new & delete). I want to access to the matrix like Matrix but i don't know how to do that...
6
by: gp | last post by:
Hi all, I'm using Microsoft Visual C++ 6.0, I would like to see, debugging my project, all the elements of my dinamic objects.... I have a dinamic array and a STL vector and I need to know...
7
by: Morgan | last post by:
I have read much posts on the argument but no one clearly says if this operation is possible or not. Simply I have a routine which reads from a text file some integer arrays (1 or 2D). The...
10
by: javuchi | last post by:
I just want to share some code with you, and have some comments and improvements if you want. This header file allocates and add and delete items of any kind of data from a very fast array: ...
0
by: Juan Segura | last post by:
Hello: I developing a filter for ISA Server. This filter is a dinamic dll not compatible with clr (Common Language Runtime). I'm trying to make a dimanic dll compatible with clr and call it...
1
by: rutigold | last post by:
i'm looking for a javaScript function to print a dinamic page. and to determine the direction of print (to the width of the page) thanks, Mikalush
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.