SQL, T-SQL, Transact-SQL, RAISERROR, Исключение с параметрами, RETURN, Прервать выполнение процедуры, Выход из процедуры
DECLARE @DateBegin datetime
DECLARE @DateEnd datetime
SET @DateBegin = 'aug 15 1969'
SET @DateEnd = 'aug 16 1969'
IF DATEDIFF(DAY, @DateBegin, @DateEnd) <> 1
BEGIN
DECLARE @@DateBegin varchar(11)
DECLARE @@DateEnd varchar(11)
SET @@DateBegin = CAST(@DateBegin AS varchar(11))
SET @@DateEnd = CAST(@DateEnd AS varchar(11))
RAISERROR ('Разница между ''%s '' и ''%s '' не равна 1', 16, 1, @@DateBegin, @@DateEnd)
RETURN
END
DECLARE @DateEnd datetime
SET @DateBegin = 'aug 15 1969'
SET @DateEnd = 'aug 16 1969'
IF DATEDIFF(DAY, @DateBegin, @DateEnd) <> 1
BEGIN
DECLARE @@DateBegin varchar(11)
DECLARE @@DateEnd varchar(11)
SET @@DateBegin = CAST(@DateBegin AS varchar(11))
SET @@DateEnd = CAST(@DateEnd AS varchar(11))
RAISERROR ('Разница между ''%s '' и ''%s '' не равна 1', 16, 1, @@DateBegin, @@DateEnd)
RETURN
END