will it alter our database?
No, it won't. Refer to this doc for more details of local variables.
A Transact-SQL local variable is an object that can hold a single data value of a specific type. Variables in batches and scripts are typically used:
- As a counter either to count the number of times a loop is performed or to control how many times the loop is performed.
- To hold a data value to be tested by a control-of-flow statement.
- To save a data value to be returned by a stored procedure return code or function return value.
How can I remove all the variables?
Just select the DECLARE lines and press Backspace. Or you could DECLARE the same variables in another batch (using the batch separator 'GO'), like this:
GO
DECLARE @date date = '04-18-2020';
DECLARE @curent_date date = getdate();
DECLARE @duedate date = getdate()+2;
SELECT @date AS 'Date', @curent_date AS 'Curent date', @duedate AS 'Due date';
GO
DECLARE @date date = '04-18-2020';
DECLARE @curent_date date = getdate();
DECLARE @duedate date = getdate()+2;
SELECT @date AS 'Date', @curent_date AS 'Curent date', @duedate AS 'Due date';
GO
Best regards,
Cosmog Hong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.