troubleshooting Question

Insert into statement

Avatar of Brandon Garnett
Brandon Garnett asked on
Microsoft SQL Server* T-SQLSQL
4 Comments2 Solutions161 ViewsLast Modified:
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.
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. Values returned by commented out section
ASKER CERTIFIED SOLUTION
ste5an
Senior Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros