November 17, 2008 at 2:13 pm
I have two Tables
Citation(CitationID, Date , ISReportTaken) and ReportExport(CitationID, ApplicationID, ISExported)
I want to insert One column records from Citation table to reportExport with ApplicationID =2 and ISExported =1 with Citation.Citationdate > '11/12/2005' to ReportExport Table
When i wrote a query it gives me invalid pointer.
Citation.CitationID column has more than 1000 records. and i want to set Citation.IsReportTaken =1 after insert into Citation table and Citation.CitationID should insert only those records which does not exist in ReportExport.
Can this be achieved in one query?
Any help please
thanks
Shailesh
November 17, 2008 at 2:19 pm
Shailesh Chaudhary (11/17/2008)
I have two TablesCitation(CitationID, Date , ISReportTaken) and ReportExport(CitationID, ApplicationID, ISExported)
I want to insert One column records from Citation table to reportExport with ApplicationID =2 and ISExported =1 with Citation.Citationdate > '11/12/2005' to ReportExport Table
When i wrote a query it gives me invalid pointer.
Citation.CitationID column has more than 1000 records. and i want to set Citation.IsReportTaken =1 after insert into Citation table and Citation.CitationID should insert only those records which does not exist in ReportExport.
Can this be achieved in one query?
Any help please
thanks
Shailesh
here is part of what your are trying to accomplish, I think:
insert into ReportExport (CitationID, ApplicationID, ISExported)
select
c.CitationID,
2,
1
from
dbo.Citation c
left outer join dbo.ReportExport r
on (c.CitationID = r.CitationID)
where
r.CitationID is null
and c.Date > '20051112' -- assuming original date was in mm/dd/yyyy format
November 17, 2008 at 2:26 pm
If you only want citations with a date > 11/12/05 that don't exist in the table, add
AND C.Date > '11/12/2005'
to the end of Lynn's query.
Also, for future reference, saying this:
When i wrote a query it gives me invalid pointer.
...is not very helpful. Instead, post the query you tried to write, and the actual error. Sometimes that will give us a better example of what you are trying to do, and we can usually tell what you're doing wrong.
For other tips on future posts, please read the article in my signature.
November 17, 2008 at 2:28 pm
Garadin (11/17/2008)
If you only want citations with a date > 11/12/05 that don't exist in the table, add
AND C.Date > '11/12/2005'
to the end of Lynn's query.
Also, for future reference, saying this:
When i wrote a query it gives me invalid pointer.
...is not very helpful. Instead, post the query you tried to write, and the actual error. Sometimes that will give us a better example of what you are trying to do, and we can usually tell what you're doing wrong.
For other tips on future posts, please read the article in my signature.
I caught the c.Date right after I posted. Thought I got back in time to fix it before anyone saw it, guess not.
November 17, 2008 at 2:29 pm
Heh, I was about to post roughly the same query, and specifically waited until you posted because I saw you reading it too :P.
November 17, 2008 at 2:44 pm
I'm flattered that you waited. I'll be honest, I don't always look to see who may be reading any given thread.
I also guess that we tend to think a like in some cases. Not sure if we have had any differences of opinion yet.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply