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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 INSERT SELECT & VALUES

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-12-18 : 09:16:49
Marcus writes "I have an issue with an insert statement

INSERT INTO table1 (ContactId,OrganizationId,Problem)
SELECT Contact.ContactId, Organization.OrganizationId
FROM Contact INNER JOIN (Organization INNER JOIN Issue ON Organization.OrganizationId = Issue.OrganizationId) ON (Organization.OrganizationId = Contact.OrganizationId) AND Contact.ContactId = Issue.CustomerId
WHERE Contact.Email = "JOHN" AND Organization.OrgCode = "ZZZ";

I have an additional value of problem which I would like to insert (Problem) that is not taken care of in the SELECT statement. How do I get this into the list?"

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2001-12-18 : 09:36:51
You can have constants in your select statement


INSERT INTO table1 (ContactId,OrganizationId,Problem)
SELECT Contact.ContactId, Organization.OrganizationId,'Problem'
FROM Contact INNER JOIN (Organization INNER JOIN Issue ON Organization.OrganizationId = Issue.OrganizationId) ON (Organization.OrganizationId = Contact.OrganizationId) AND Contact.ContactId = Issue.CustomerId
WHERE Contact.Email = 'JOHN' AND Organization.OrgCode = 'ZZZ'


Btw, you should use ' rather than " as a string delimiter.

Go to Top of Page
   

- Advertisement -