[dba-SQLServer] How do I

jwcolby jwcolby at colbyconsulting.com
Fri Dec 7 00:09:15 CST 2007


I have created an SProc that accepts a field name and a Field ID, and looks
up the data in that field name (in a fixed source table for now).  It then
writes the data and the Field ID into my "vertical table".

The next "higher" piece needs to look up that Field Name and Field ID in a
table of field names (I have that already) and the call the SProc mentioned
above that I just created, passing off the values from the Field name and
Field ID columns.  I can get the table values (build the SQL to do that).
What I do not know how to do is to execute a loop moving through the
recordset and calling the SProc with the values pulled all inside of a
"supervisor" SProc.

Can someone point me to or write air code to do this?

Basically I have a table with 600 fields.  I have a field name table where I
pulled the field names and poured them into a field name table with an
autoincrement ID so I now have a Fld_ID, Fld_Name.  I need to read the ~600
records in this table and one by one pass off the FLD_ID and FLD_Name to my
existing sproc.  That existing sproc will pull the data from the "horizontal
table" and store it into my "vertical table".

Once I finish this exercise I will have the system that Arthur has been
harping on me to build.  Then I can build a cover index and start some
testing to see how fast it ends up being vs. running a similar query on the
original "horizontal table".

Any help would be appreciated.

John W. Colby
Colby Consulting
www.ColbyConsulting.com 




More information about the dba-SQLServer mailing list