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
 General SQL Server Forums
 New to SQL Server Programming
 Predicament

Author  Topic 

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2009-09-18 : 16:13:30
Hi Group of Live Savers:

Ok. I have a table Approvers
[Code]
select id, location_Code, Application, Responsibility_Begins_with, Approver_Main, AppMain_UserId, Approver_BackUP, AppBackUp_UserId, GSP_Team_FYI
From Approvers
WHERE id = @id [/code]

I need to insert the record from the Approver Table into
INSERT INTO ApproverLogs(id,Location_Code,Application, Responsibility_Begins_With, Approver_Main, AppMain_UserID, Approver_BackUp,AppBackUp_UserID,GSP_TEAM_FYI, Change_By, Change_Datetime, Change_type)

As you can see the First Table match almost all columns from the Second Table except from change_by, Change_Datetime and Change_Type.

ok.
I want to be able to copy the record from the first table into the second table and added variables for Change_by, Change_Datetime and Change_type.

Thank you for all your help!!!!!!!!!!!!

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-09-18 : 16:34:08
So what is the question?

this is the syntax for inserting into one table by a select from another plus some parameters:

INSERT INTO ApproverLogs
(id
,Location_Code
,Application
,Responsibility_Begins_With
,Approver_Main
,AppMain_UserID
,Approver_BackUp
,AppBackUp_UserID
,GSP_TEAM_FYI
,Change_By
,Change_Datetime
,Change_type)

select id
,Location_Code
,Application
,Responsibility_Begins_With
,Approver_Main
,AppMain_UserID
,Approver_BackUp
,AppBackUp_UserID
,GSP_TEAM_FYI
,@Change_By
,@Change_Datetime
,@Change_type
From Approvers
WHERE id = @id



Be One with the Optimizer
TG
Go to Top of Page

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2009-09-18 : 17:01:53
Thank you TG :) you rock!!!
Go to Top of Page
   

- Advertisement -