473,320 Members | 1,950 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,320 software developers and data experts.

Dynamic SQL query Multiple rows based on table names linked in another table

1
Hello
I have a sql 2008 R2 problem that I’ve tried to accomplishing using dynamic sql but, no luck yet.
Expand|Select|Wrap|Line Numbers
  1. Create Table Events (
  2. PKID    int  Not Null,
  3. TimeStamp Datetime,
  4. EventID        int,
  5. Eventdata     int)
  6.  
  7. Create Table Eventdatalookup(
  8. Event    int,
  9. DataLookupTableName         varchar(100))
  10.  
  11. Create Table TypicalEventDesc1(
  12. EventData     int
  13. EventDataDesc        varchar(100)
  14. Create Table TypicalEventDesc2(
  15. EventData     int
  16. EventDataDesc        varchar(100)
  17.  
Im wanting to create a stored procedure that will lookup the description of the event id and event data in table Events based on a table name in another table. I have found examples of dynamic sql that will return the Desc for one row but there will be many many rows returned in this query.

Events.EventID--- EventDataLookup.Event
Events.EventData—TypicalEventDescX.EventData
The DataLookupTableName Contains the name of the table from which the Events.EventData can be tied to TypicalEventDesc1.EventDataDesc or tied to TypicalEventDesc2.EventDataDesc


Is what I’m wanting to do even possible?
Dec 7 '11 #1
1 1764
Rabbit
12,516 Expert Mod 8TB
It's possible. The real question is why is the event data split across multiple tables when they should be in one table?
Dec 7 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: sheree | last post by:
I have 3 tables (amoung a few others) in a small access database. The tables are as follows: == AEReport -------- AEID (PK) RptCatelog GCRCID PatientID EvntDate
2
by: S0ck3t | last post by:
Please could I have some help on matching records between tables. I want to return a check (true/false) stating whether the field combination in table 1 occurs in table 2. Obviously it's easy with...
4
by: Joanie | last post by:
I have a form that records dates of unavailability for a worker. Based on what is entered in the simple table behind the form, many calculations take place to create employee "load" balance. Each...
2
by: Bone | last post by:
Hello, first off I have generally been able to find most the info I needed by searching through the board for it. However I couldnt find anything pertianing to this so I decided it was probably time...
5
by: joshua.nicholes | last post by:
I have an access database that consists of two tables.A data collection table and a species list table. The data collection table has about 1500 records in it and the species list has about 600....
0
by: acesfull | last post by:
Hi, I am trying to do something in SQL that I have done in PHP, but I am trying to have the operation performed as a stored procedure because of the sheer number of inserts I have to perform in PHP. ...
2
gchq
by: gchq | last post by:
Hi there This was the closest to Sybase I could see.... If I wanted to perform a multiple insert based on values in a table using, say a web app, I'd define a DataTable and bring in the...
3
by: Vinda | last post by:
Hi Bytes, Using a previous question as a base Access 2000 Inserting multiple rows based on a date range. I also wanted to insert multiple rows into a table according to a date range supplied by a...
13
by: santhanalakshmi | last post by:
Hi, I am working on SQL 2008 database. In Micosoft SQL server Management studio, i am trying to insert multiple records at a time in a table, using this query insert into...
1
by: Arielle | last post by:
Problem: I have a few related tables that collects information about a given publication. The information collected varies based on the type of collection and is stored in a few different tables. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.