Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MS SQL Insert Through Select Statement

Posted on 2006-07-04
1
Medium Priority
?
450 Views
Last Modified: 2008-03-06
Sir, I am using following command to insert some information from an other table

Insert Into BrcOffExp(ExpDate,Discriptions,credit) values (select x.ExpDate,x.JobNo,x.Amount
from
(select ExpDate=max(a.cbd),JobNo='Job # ' + left(a.file_job,5) + 'Peshawar Expense', Amount=sum(a.RahdariCost)+sum(a.TurkhamClearanceExp)
from cntrtransporterdet a
where a.cbd >='06/01/2006'
and a.Cbd <='06/30/2006'
group by a.file_job)x
where amount > 0


Please let me know where i am doing mistake because it is showing error on line first near select.

Rgds.
Mehram
0
Comment
Question by:Mehram
[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
1 Comment
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 2000 total points
ID: 17035470
Hi Mehram,
Insert Into BrcOffExp(ExpDate,Discriptions,credit)
select x.ExpDate,x.JobNo,x.Amount
from
(
select ExpDate=max(a.cbd),JobNo='Job # ' + left(a.file_job,5) + 'Peshawar Expense',
Amount=sum(a.RahdariCost)+sum(a.TurkhamClearanceExp)
from cntrtransporterdet a
where a.cbd >='06/01/2006'
and a.Cbd <='06/30/2006'
group by a.file_job)x
where amount > 0


Cheers!
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

610 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