Brandon Garnett
asked on
Insert into statement
I am trying to Insert values into a table using the following query and I get Query completed with errors and I don't know what is causing it.
The part commented out returns 6 rows. I want to put those rows into a table and then a hard coded value of @gSource for all of them.
Declare @gSource int;
Declare @bSource int;
Set @gSource = 143692;
Set @bSource = 138450;
/*SELECT ProjectID, BinderSection,BinderTab
FROM hcc_tblProjects2Sources
WHERE SourceID = @bSource
EXCEPT
SELECT ProjectID, BinderSection,BinderTab
FROM hcc_tblProjects2Sources
WHERE SourceID = @gSource;
*/
INSERT INTO hcc_tblProjects2Sources(ProjectID, BinderSection, BinderTab, SourceID)
VALUES(
(SELECT ProjectID, BinderSection,BinderTab
FROM hcc_tblProjects2Sources
WHERE SourceID = @bSource
EXCEPT
SELECT ProjectID, BinderSection,BinderTab
FROM hcc_tblProjects2Sources
WHERE SourceID = @gSource)
,@gSource
);
The part commented out returns 6 rows. I want to put those rows into a table and then a hard coded value of @gSource for all of them.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you seems to be working great
ASKER