I know my title isn't exactly worded well, so let me clarify. I'm using SQL Server 2005 Express.
I have a table that basically stores a "template," if you will. Using a car as an example, the fields would be something like:
TemplateID
Color
Make
Model
Now, I have another table that represents an "instance" of the template. It contains all the fields of the template table plus some fields that are unique to an instance:
InstanceID
VIN
SerialNumber
Color
Make
Model
I am writing a stored procedure to insert a new row into the "Instance" table. This stored procedure will take input parameters for "VIN" and "SerialNumber," but I want it to copy "Color", "Make", and "Model" from the appropriate "Template." The template is located by the "TemplateID," which is already known.
I am looking for advice on how to write this stored procedure. It would be simple if it weren't for the fact that these tables contain 100+ fields (I didn't design them but I'm stuck using them.) I would like to do something like:
INSERT INTO Instance(VIN, SerialNumber, "EverythingElse")
VALUES (@VIN, @SerialNumber, SELECT * FROM Template WHERE TemplateID = 1)
In other words, I only want to supply (through parameters) those fields not stored in the "Template" and copy everything else from the template. Is anything like this possible without hand coding for every field?