Answer the question
In order to leave comments, you need to log in
How to create a procedure with queries in SQL?
How to create a procedure with input parameters that changes in the database, for example: the full name of the head of the district, when entering the name of the district and the full name of the head of the district.
Answer the question
In order to leave comments, you need to log in
Well, something like this:
/*
Входные параметры:
@DistrinctName - название района
@NewFIO - новые ФИО главы
таблица District например содержит поля название района и ФИО главы
Коды возврата процедуры:
0 -Штатное завершение (процедура отработала нормально)
-1000 - не указано (или пустое) название района
-1001 - не указано (или пустое) новое имя главы
-1002 - района с таким названием не существует
*/
create procedure dbo.upd_FIO
@DistrinctName varchar(150)
, @NewFIO varchar(1024)
as
begin
if isnull(@DistrictName, '') = ''
return -1000
if isnull(@NewFIO, '') = ''
return -1001
if not exists (select top 1 1 from District where DistrictName = @DistrictName)
return -1002
update District set FIO = @NewFIO
where DistrictName = @DistrictName
return 0
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question