sql - Deleting a user and the user profile -


i'm new sql , stored procedures, , need stored procedure below. have tables connected each other: "user" , "profile".

when deleting user user profile should deleted, , that's sp below does. however, when executing sp userids in table user shows (of course because of "select userid), , don't want.

so, guess question how write sp works without using select?

thanks in advance.

create procedure usp_deleteuser @userid int begin   begin try     begin transaction;         select u.userid          [user] u inner join profile p              on u.userid = p.userid;          delete profile         userid = @userid;          delete [user]         userid = @userid;      commit transaction;     end try     begin catch         rollback transaction         raiserror ('borttagningen gick inte att genomföra!',16,1)     end catch end go 

profile.userid should foreign key indicating one-to-one relationship user table, on delete cascade specified. delete record user table, , associated record in profile table automatically removed.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -