Skip to content

Commit d399998

Browse files
authored
capitalized keywords
1 parent 75ed152 commit d399998

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

docs/t-sql/language-elements/variables-transact-sql.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ The following script creates a small test table and populates it with 26 rows. T
3737

3838
```sql
3939
-- Create the table.
40-
CREATE TABLE TestTable (cola int, colb char(3));
40+
CREATE TABLE TestTable (cola INT, colb CHAR(3));
4141
GO
4242
SET NOCOUNT ON;
4343
GO
4444
-- Declare the variable to be used.
45-
DECLARE @MyCounter int;
45+
DECLARE @MyCounter INT;
4646

4747
-- Initialize the variable.
4848
SET @MyCounter = 0;
@@ -84,20 +84,20 @@ The DECLARE statement initializes a Transact-SQL variable by:
8484

8585
For example, the following **DECLARE** statement creates a local variable named **\@mycounter** with an int data type.
8686
```sql
87-
DECLARE @MyCounter int;
87+
DECLARE @MyCounter INT;
8888
```
8989
To declare more than one local variable, use a comma after the first local variable defined, and then specify the next local variable name and data type.
9090

9191
For example, the following **DECLARE** statement creates three local variables named **\@LastName**, **\@FirstName** and **\@StateProvince**, and initializes each to NULL:
9292
```sql
93-
DECLARE @LastName nvarchar(30), @FirstName nvarchar(20), @StateProvince nchar(2);
93+
DECLARE @LastName NVARCHAR(30), @FirstName NVARCHAR(20), @StateProvince NCHAR(2);
9494
```
9595

9696
The scope of a variable is the range of Transact-SQL statements that can reference the variable. The scope of a variable lasts from the point it is declared until the end of the batch or stored procedure in which it is declared. For example, the following script generates a syntax error because the variable is declared in one batch and referenced in another:
9797
```sql
9898
USE AdventureWorks2014;
9999
GO
100-
DECLARE @MyVariable int;
100+
DECLARE @MyVariable INT;
101101
SET @MyVariable = 1;
102102
-- Terminate the batch by using the GO keyword.
103103
GO
@@ -113,7 +113,7 @@ WHERE BusinessEntityID = @MyVariable;
113113
Variables have local scope and are only visible within the batch or procedure where they are defined. In the following example, the nested scope created for execution of sp_executesql does not have access to the variable declared in the higher scope and returns and error.
114114

115115
```sql
116-
DECLARE @MyVariable int;
116+
DECLARE @MyVariable INT;
117117
SET @MyVariable = 1;
118118
EXECUTE sp_executesql N'SELECT @MyVariable'; -- this produces an error
119119
```
@@ -128,8 +128,8 @@ To assign a variable a value by using the SET statement, include the variable na
128128
USE AdventureWorks2014;
129129
GO
130130
-- Declare two variables.
131-
DECLARE @FirstNameVariable nvarchar(50),
132-
@PostalCodeVariable nvarchar(15);
131+
DECLARE @FirstNameVariable NVARCHAR(50),
132+
@PostalCodeVariable NVARCHAR(15);
133133

134134
-- Set their values.
135135
SET @FirstNameVariable = N'Amy';
@@ -148,7 +148,7 @@ A variable can also have a value assigned by being referenced in a select list.
148148
```sql
149149
USE AdventureWorks2014;
150150
GO
151-
DECLARE @EmpIDVariable int;
151+
DECLARE @EmpIDVariable INT;
152152

153153
SELECT @EmpIDVariable = MAX(EmployeeID)
154154
FROM HumanResources.Employee;
@@ -163,7 +163,7 @@ If a SELECT statement returns more than one row and the variable references a no
163163
```sql
164164
USE AdventureWorks2014;
165165
GO
166-
DECLARE @EmpIDVariable int;
166+
DECLARE @EmpIDVariable INT;
167167

168168
SELECT @EmpIDVariable = BusinessEntityID
169169
FROM HumanResources.Employee

0 commit comments

Comments
 (0)