Sql updating table variable

One reason would be the automation of administrative tasks.

Let’s say you have a non-production server with every limited space and you want to make sure that all the databases on your server are in simple recovery mode (to minimize the growth of the transaction logs).

But the snippets I provide should provide enough information to show how to use this method.

My goal is to find out if any databases are not in the simple recovery model.

Although it’s not quite cognitive, it can be used to handle a lot of tasks that would likely be repetitive or have a high administrative overhead.

Also note that as long as the SQL statement itself remains the same, yet only the parameters change, the query optimizer will utilize the same cached execution plan.EXEC (sqlstatement) You can even place the piece of code into a variable and put the variable in parenthesis.(Note that EXEC allows the use of both regular character strings and Unicode character strings as input).Here is a quick example: We just assigned the INT variable @maxrecord with a value of 10.This can change throughout a SQL script, thus providing great flexibility.

Leave a Reply