stored procedures - How can I copy all fields of one table to another, wider table in SQL Server 2005 Express? -


I know that my title is not quite right, so make me clear. I'm using SQL Server 2005 Express.

I have a table that basically stores "template", if you do. Using a car as an example, the field will look something like this:

  Template ID color make model  

Now, I have another table that The template "represents the instance" contains all the fields in the template table and some fields that are unique to an example:

  Instant VIN Serial Number Color Make Model   

I'm typing a new row in the "Instance" table Stored procedure Alne will input parameters for the stored procedure "VIN" and "serial number", but I want to copy it to the appropriate "template" and "color", "make" and "model". The template is located by "Template ID", which is already known.

I am looking for advice on how to write this stored procedure. It would be easy if this is not the fact that 100 fields in these tables (I did not design them, but I am using them). I want to do something like this:

  Instant ( VIN, serial number, "Everything Else") INSERT (@VIN, @SerialNumber, SELECT * from template WHERE TemplateID = 1)  

In other words, I only want ( Through parameters) do not store those fields in "Templates" and all from the template To six copies. Is there anything possible without hand coding for every field?

Just make any INSERT and use a SELECT statement instead of a statement. INSERT INSERT IN INSTANT (VIN, CERIAL NUMBER, A, B, C) WEIN, SEERAL NO, A, B, C, WAPE TemplateID = 1;

You do not really want * to use * You may have a selection statement for the SQL Server Management Stenary script and this will generate field names so you do not have to type them.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -