Stored procedure

Database
Fan

Stored procedure

Hello,

I have been struggling with this concept and any help would be highly appreciated. Do we need a stored procedure here? here is a small mock up example, however this will be implemented on a large scale.

Table 1

VariableName Estimate
Dog -0.0373
Cat 9.8
Hen 1.23

Table 2

name EmployeeID Dog Hare Goat cat Hen
anb 12 4 2 6 3 6
mamn 2 2 4 4 2 2
kann 6 6 2 5 8 0

Step 1 Result:

Take all the variablename from table 1 (Without refering to them like dog, hen etc.,) and get records only for those values in the table 2 (plus name and employee ID)

name EmployeeID Dog cat Hen
anb 12 4 3 6
mamn 2 2 2 2
kann 6 6 8 0

Thanks,
KG
1 REPLY
Junior Contributor

Re: Stored procedure

You need Dynamic SQL to create a matching Select-statement, there's no way to do that outside of a Stored Procedure.