Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL Record Source

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-05-25 : 08:39:55
Chris writes "Below is the query which pulls the records. This query is used for the homepage (to keep it updated).

Two questions:

1. When I get the recordset into ASP, I need the table name to re-query the DB for the rest of the information. However, I don't know how to retrieve the source table of the record. How do I do this?

2. If there is another method, could you please make recommendations (and provide a sample or re-arranged code)?

Query which pulls the X (3) latest records from the database (it's not a very large DB, so I'm using the UNION ALL..):

SQl = "SELECT TOP 3 id, title, date" & _
"FROM" & _
"(SELECT tbl_calendar.id, tbl_calendar.title, tbl_calendar.date" & _
"FROM tbl_calendar" & _
"UNION ALL" & _
"SELECT tbl_news.id, tbl_news.title, tbl_news.date" & _
"FROM tbl_news" & _
"UNION ALL" & _
"SELECT tbl_places.id, tbl_places.title, tbl_places.date" & _
"FROM tbl_places" & _
"UNION ALL" & _
"SELECT tbl_links.id, tbl_links.title, tbl_links.date" & _
"FROM tbl_links" & _
"ORDER BY date ASC" & _
")" & _
"ORDER BY date DESC;""
   

- Advertisement -