?
Solved

MS SQL Insert Through Select Statement

Posted on 2006-07-04
1
Medium Priority
?
442 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
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…
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…

771 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