Advertisement

04.03.2008 at 08:06AM PDT, ID: 23293046
[x]
Attachment Details

MSSQL INSERT from Table

Asked by bergstrom_davin in MS SQL Server

I have a table that I want to insert a new record, with some hard values, but use an existing value for one of the fields if it exists.

INSERT INTO adm_testing
(EmailID, StartDate, Program, ForcedProgram, [Password])
VALUES ('myemail@gmail.com','1207234031','','',(       SELECT  TOP 1 EmailID
                                                        FROM    adm_testing
                                                        WHERE   EmailID = 'myemail@gmail.com'                        ))

I get "Subqueries are not allowed in this context. Only scalar expressions are allowed."

Thanks in advance!Start Free Trial
[+][-]04.03.2008 at 08:09AM PDT, ID: 21273467

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Sign Up Now!
Solution Provided By: ee_rlee
Participating Experts: 2
Solution Grade: A
 
 
[+][-]04.03.2008 at 08:11AM PDT, ID: 21273488

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.03.2008 at 08:12AM PDT, ID: 21273499

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.03.2008 at 08:13AM PDT, ID: 21273502

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628