sql server - SQL procedure to add and edit data -



sql server - SQL procedure to add and edit data -

im busy old exam paper 1 of questions read follows

study next tables , reply questions below:

create table cardholders( ch_id integer identity, ch_name varchar(50), ch_surname varchar(50), ch_idnumber char(13), ch_cardnumber char(13), ch_status char(2), ch_create_date datetime, ch_last_change_date datetime)

write store procedure add together or edit cardholders information. neccecary validation checks ensure info correct.

my answer

create procedure add_ch (@ch_name, @ch_surname...) begin insert cardholders values (@ch_name, @ch_surname...) end

to run procedure

execute add_ch ('peter', 'kemp')

my question

will above procedure add together cardholer give right results? the question asks 'write store procedure add together or edit cardholders information' how combine add together procedure edit cardholder procedure or right in assuming can have different procedure?

are looking this?

create procedure add_ch (@ch_name , @ch_surname...) begin declare @count int set @count = (select count (*) cardholders ch_name = @ch_name , ch_surname = @ch_surname) if @count = 0 insert cardholders values (@ch_name, @ch_surname...) else print'this user exsit.' end

sql sql-server stored-procedures

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -