Solved

MS SQL Insert Through Select Statement

Posted on 2006-07-04
1
430 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 500 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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…

726 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