Showing posts with label appears. Show all posts
Showing posts with label appears. Show all posts

Monday, March 12, 2012

Help with query

Hi, I would like some help with a query. I would like to delete all
rows when the key appears in one table and not the other. For example
the info in table 1 on my DB is my current work. I then import the upto
date info monthly into table 2. Currently I have to manually delete the
info from table 2, hence the need for the query to mismatch and leave
me with the current info.
Hope this makes sense
Thanks)It's ususally a good idea to start a new thread so that your request for he
lp doesn't get lost in someone else's responses. Also good to provide table
DDL and sample data in the form of INSERT statements.)
One way to do this is:
DELETE Table2
WHERE Table2.Key IN ( SELECT Table1.Key
FROM Table1
WHERE {criteria in Table1}
)
Or vice versa to delete from Table1
Let me know if this helps.
--
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"John" <john_sarah_kerr@.hotmail.co.uk> wrote in message news:1151180034.679815.100870@.b68g2
000cwa.googlegroups.com...
> Hi, I would like some help with a query. I would like to delete all
> rows when the key appears in one table and not the other. For example
> the info in table 1 on my DB is my current work. I then import the upto
> date info monthly into table 2. Currently I have to manually delete the
> info from table 2, hence the need for the query to mismatch and leave
> me with the current info.
>
> Hope this makes sense
>
> Thanks
>

Wednesday, March 7, 2012

Help with OpenXML

Hi,
I am trying to insert an XML document into into 3 tables which match the
hierachy of the xml and which appears to be working. This data could be an
update or an insert so for simplicity I have an initial procedure which
clears down the existing data using a cascading delete. This too appears to
be working.
However, when I check the tables there appears to be hundreds of duplicate
rows ? Has anybody come across anything similar. The tables do have an
identity field within them, which might be causing an issue I guess.
I am using SQL Server 2000 (sp3) on a Windows 2000 Server box.
Grateful for any helpJust realised we are actually using sp4 which might explain the problem, as
I
am using @.mp/@.parentid ?
"Redowl" wrote:

> Hi,
> I am trying to insert an XML document into into 3 tables which match the
> hierachy of the xml and which appears to be working. This data could be a
n
> update or an insert so for simplicity I have an initial procedure which
> clears down the existing data using a cascading delete. This too appears
to
> be working.
> However, when I check the tables there appears to be hundreds of duplicate
> rows ? Has anybody come across anything similar. The tables do have an
> identity field within them, which might be causing an issue I guess.
> I am using SQL Server 2000 (sp3) on a Windows 2000 Server box.
> Grateful for any help