?
Solved

insert values using Select

Posted on 2007-11-14
2
Medium Priority
?
367 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

by:
Terry Woods earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

765 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