Solved

insert values using Select

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

856 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