# Шаблон ХП

```
/******************************************************************************
**	
*******************************************************************************/
create procedure dbo.
as
set nocount on
set xact_abort on
declare @transactionCount int
begin try
	--
	set @transactionCount = @@trancount
	if (@transactionCount = 0)
		begin transaction

	--
	
	if (@transactionCount = 0)
		commit transaction
end try
begin catch
	declare @errorNumber int, @errorMessage nvarchar(4000), @errorSeverity int, @errorState int
	
	select 
		@errorNumber = error_number(),
		@errorMessage = error_message(),
		@errorSeverity = error_severity(),
		@errorState = error_state();
		
	if (@transactionCount = 0 and @@trancount > 0)
		rollback transaction;
		
	raiserror(@errorMessage, @errorSeverity, @errorState)
end catch;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://projects.itproduct.ru/azimut/dokumentaciya/shablon-khp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
