About 33,800,000 results
Open links in new tab
  1. SQL Variables: Basics and usage - SQL Shack

    Nov 18, 2019 · In this article, we will learn the notions and usage details of the SQL variable. In SQL Server, local variables are used to store data during the batch execution period. The local variables can be created for different data types and can also be assigned values.

  2. Variables (Transact-SQL) - SQL Server | Microsoft Learn

    Nov 22, 2024 · 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.

  3. How to Use SQL Variables in Queries

    Mar 7, 2021 · Learn how to use SQL variables in queries to make your SELECT statements accept a greater variety of conditions.

  4. How to Declare a Variable in SQL Server? - GeeksforGeeks

    Aug 23, 2024 · By using the DECLARE statement, you can create variables with specific data types, which can then be assigned values using the SET or SELECT commands. In this article, We will learn about How to declare a variable in SQL Server by understanding various scenarios in detail. To declare a variable in SQL Server, use the DECLARE statement.

  5. How to set variable from a SQL query? - Stack Overflow

    There are three approaches: Below query details the advantage and disadvantage of each: , @test2 int = (SELECT a from (values (1),(2)) t(a)) -- throws error. -- Advantage: ANSI standard. ,@test2 = (SELECT a from (values (1),(2)) t(a)) -- throws error.

  6. How to Declare a Variable in SQL? - GeeksforGeeks

    Dec 30, 2024 · Understanding how to declare and use variables in SQL enables developers to write efficient, scalable, and dynamic queries. Whether using the SET command, WITH clause, temporary tables, or subqueries, each method offers unique advantages for handling data.

  7. SQL Declare Variable Code Examples - MSSQLTips.com - SQL

    Dec 30, 2024 · Learn how to define and use variables in SQL Server code with these many different SQL Declare Variable code examples.

  8. SQL Variables for T-SQL Code and Queries - MSSQLTips.com - SQL

    Jul 20, 2023 · In T-SQL, a local variable is described as an object that can hold a scalar value (single data value) of a specific data type. To learn more about what a T-SQL local variable is used for, continue to read the Microsoft documentation: Variables (Transact-SQL).

  9. Learn SQL Variables for Scripts and Development

    Dec 21, 2022 · In this tutorial, we take a look at declaring and using variables in SQL statements. Let’s start at the beginning with the understanding that SQL variables are not created, but rather, they are declared. Yes, there is a difference. To create means that you have created an object in SQL Server that will remain after you close your SQL instance.

  10. Variables in SQL Server Stored Procedures - SQL Server Tutorial

    Summary: in this tutorial, you will learn about variables including declaring variables, setting their values, and assigning value fields of a record to variables. A variable is an object that holds a single value of a specific type e.g., integer, date, or varying character string. We typically use variables in the following cases:

Refresh