Solved

insert values using Select

Posted on 2007-11-14
2
321 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
Comment Utility
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
Comment Utility
thanks that worked!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

16 Experts available now in Live!

Get 1:1 Help Now