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 2005 Forums
 Transact-SQL (2005)
 Query Help

Author  Topic 

Nexzus
Starting Member

14 Posts

Posted - 2015-03-25 : 18:32:05
I have tables in a vendor supplied SQL-2005 DB that look like this

"TPUSRDEF"

PUProbNo | PUDef1 | PUDef2 | ... | PUDef10

PUProbNo is an int. PUDef1 to 10 can be null, and the application has made it so one row can have a value for PUDDef2, but PUDef1 is null. They are varchars with the format [{######}], but I can extract the number easily enough, as I need to join with...

"MAIN_OBJINDEX":
lID | DataColumn2 | DateColumn3 | etc. (Not their actual names, but it's not important

lID is an int, which corresponds to the number in one of the PUDef# columns in "TPUSRDEF"

Why a company would use a database like this I have no idea.

What I need:

Rows of DataColumn2, DataColumn3, etc from MAIN_OBJINDEX for a given, single, PUProbNo in TPUSRDEF

Sample Data 1:

TPUSRDEF:
PUProbNo = 1 | PUDef1 = NULL | PUDef2 = [{123}] | ...

MAIN_OBJINDEX:
lID = 123 | DataColumn1 = "Some Data" | DataColumn2 = "Some More Data | etc...

Needed Output 1:
TheSelectQueryGivenToMeByTheAwesomeMembersofSQLTeam(PUProbNo = 1)
============
"Some Data", "Some More Data"

Sample Data 2:
TPUSRDEF:
PUProbNo = 2 | PUDef1 = NULL | PUDef2 = [{456}] | PUDef3 = NULL | PUDef4 = [{789}] | ...

MAIN_OBJINDEX:
lID = 456 | DataColumn1 = "Some 456 Data" | DataColumn2 = "Some More 456 Data" | etc...
lID = 789 | DataColumn1 = "Some 789 Data" | DataColumn2 = "Some More 789 Data" | etc...

Needed Output 2:
TheSelectQueryGivenToMeByTheAwesomeMembersofSQLTeam(PUProbNo = 2)
============
"Some 456 Data", "Some More 456 Data"
"Some 789 Data", "Some More 789 Data"

Thank you kindly.

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-03-26 : 09:58:02
Help us help you!


http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -