SQLQuery for SQl 2000

  • 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

  • Shailesh Chaudhary (11/17/2008)


    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

    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

  • 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.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • 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.

  • Heh, I was about to post roughly the same query, and specifically waited until you posted because I saw you reading it too :P.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • 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