Link to home
Start Free TrialLog in
Avatar of repzat
repzat

asked on

help with a query

Hi, I have this need:

I have 2 tables, between these tables there is a 'one to many' relationship based on the 'guid' (of type uniqueidentifier) field.

> If I want to join the results from the 2 tables I do:

SELECT * FROM A,B
where A.guid = B.guid
and A.deleted = 0

> and if I want to count the records where the field 'deleted' (of type bit) is = 1 I do:

SELECT count(*) FROM A,B
where A.guid = B.guid
and A.deleted = 1

Now I need a query to use *inside a stored procedure and with transaction support* that allows me to

- GET all the records in table B where the field 'deleted' (wich is in table A) is = 1
- COPY the records from table B where 'deleted' is = 1 to another table C with the *same structure*
   of the table B
- DELETE the records from table B where 'deleted' is = 1

Thanks and regards

ASKER CERTIFIED SOLUTION
Avatar of appari
appari
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of repzat
repzat

ASKER

perfect appari, the points are yours. Just could you please put also support for transations?

Thanks and regards