SQLTeam.com | Weblogs | Forums

Help to deleting content in a table

tsql

#1

in my database i try to dele the old user .but i cant dellet them. the mssql say.
Error -2147217873

The DELETE statement conflicted with the REFERENCE constraint "FK_PrizeRescueRequest_User". The conflict occurred in database "DB_A1AD3A_test", table "dbo.PrizeRescueRequest", column 'user_id'.

DELETE FROM [DB_A1AD3A_test].[dbo].[User] WHERE 1=0 OR ( [id] = 16 )

but i cant delet the info in PrizeRescueRequest ...how do i emty PrizeRescueRequest content
without deleting the database


#2

Probably like this:

delete
  from DB_A1AD3A_test.dbo.PrizeRescueRequest
 where user_id=16
;

But before you delete anything, first validate that you "hit" the results you want by doing a select:

select *
  from DB_A1AD3A_test.dbo.PrizeRescueRequest
 where user_id=16
;

#3

... and that nothing else needs that row to still remain in the database :slight_smile:


#4

thanks it works