Solved

insert values using Select

Posted on 2007-11-14
2
343 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Server Update Query Streamline 4 29
Join multiple pivot queries 2 17
SQL Server 2012 r2 - calculations/operation on many Temp Tables 6 21
VB.net and sql server 4 36
'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 …
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. …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

810 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