Simple way to save parameters

Simple way to save parameters

Sometimes there is the need to log the startup parameters of a stored procedure. Or maybe be able to send them to a service broker for asynchronous execution.

One simple way to do it is using the for xml clause. Of course there is the need for some manual work (or maybe not).

The code however would look like this:

declare @params xml = 
	(
		select
			@Parameter1
			,@Parameter2
			,@Parameter3
			,@TableValuedParameter4
		for xml raw, type
	);

Now the @params variable is ready to be used / logged / sent forward.

Comments are closed.