Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Adding Rows to an existing table sql 2005


Adding Rows to an existing table sql 2005

Author
Message
kgeeel240
kgeeel240
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 34
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
Kingston Dhasian
Kingston Dhasian
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3005 Visits: 5016
You will have to use an INSERT..SELECT option

INSERT   INTO [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

INSERT   INTO [PLSy]( <<Column1>>, <<Column2>>, ....<<Columnn>> )
SELECT <<Column1>>, <<Column2>>, ....<<Columnn>>
FROM [srv5].[DB].[dbo].[PLSo] AS Nav-- Navision
WHERE NOT 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/
kgeeel240
kgeeel240
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 34
hi

thank you i will try it and get back to u
kgeeel240
kgeeel240
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 34
Thank you it worked!!!!w00t
Kingston Dhasian
Kingston Dhasian
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3005 Visits: 5016
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/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search