Adding Rows to an existing table sql 2005

  • hi

    i have a table from navision PLSo that is being updated every hour now i have created a table on my server PLSy now i want PLSo to update PLSy after 30 min it has got that info .. i don't mind doing it by my self if i cannot schedule it..Please help with the statement.. PLSo has a field that is never duplicated so i used it to say PLSo give everything(new rows that are captured on you) that PLSy do not have

    select * into [PLSy] from [srv5].[DB].[dbo].[PLSo]--Navision

    where [timestamp] not in (select [timestamp] from [PLSy])

    I tried using this statement it does not work since the table is there so for the past week i have been deleting and re creating this table

    please help

  • You will have to use an INSERT..SELECT option

    INSERTINTO [PLSy]( <<Column1>>, <<Column2>>, ....<<Columnn>> )

    SELECT<<Column1>>, <<Column2>>, ....<<Columnn>>

    FROM[srv5].[DB].[dbo].[PLSo] -- Navision

    WHERE[timestamp] NOT IN ( SELECT [timestamp] FROM [PLSy])

    Another better way would be to use NOT EXISTS instead of NOT IN

    INSERTINTO [PLSy]( <<Column1>>, <<Column2>>, ....<<Columnn>> )

    SELECT<<Column1>>, <<Column2>>, ....<<Columnn>>

    FROM[srv5].[DB].[dbo].[PLSo] AS Nav-- Navision

    WHERENOT EXISTS( SELECT * FROM [PLSy] AS PL WHERE PL.[timestamp] = Nav.[timestamp] )


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • hi

    thank you i will try it and get back to u

  • Thank you it worked!!!!:w00t:

  • kgeeel240 (4/29/2013)


    Thank you it worked!!!!:w00t:

    Glad it helped:-)


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply