Solved

insert values using Select

Posted on 2007-11-14
2
332 Views
Last Modified: 2008-02-01
I am trying to get a value to insert into a table from a table and get the following error:
Subqueries are not allowed in this context. Only scalar expressions are allowed.
Here is the query.
Insert into [dbo].[tblRpt_Param]
(ReportName,    
Previous_Run_Date,  
Current_Run_Date)

Values ('AXA_Approved_Accts',Null,(Select Max(CrtDate)From [transaction].dbo.narrstatushistory))

0
Comment
Question by:donnie91910
2 Comments
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 total points
ID: 20284572
Try:

Insert into [dbo].[tblRpt_Param]
          (ReportName,    
           Previous_Run_Date,  
           Current_Run_Date)
select 'AXA_Approved_Accts',
          Null,
         Max(CrtDate)
From [transaction].dbo.narrstatushistory

Note that if there are columns other than crtdate in the narrstatushistory table, you'll need to add a "group by <col1>, <col2>..." for every column other than crtdate to the end of the query.
0
 

Author Comment

by:donnie91910
ID: 20284622
thanks that worked!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now