About 165,000 results
Open links in new tab
  1. How to set variable from a SQL query? - Stack Overflow

    I'm trying to set a variable from a SQL query: declare @ModelID uniqueidentifer Select @ModelID = select modelid from models where areaid = 'South Coast' Obviously I'm not doing this right …

  2. sql server - how to declare variable in TSQL and use in multiple ...

    Apr 12, 2018 · How can I declare a variable in T-SQL and use it in multiple statements? For example:

  3. sql - How to declare a variable in MySQL? - Stack Overflow

    Aug 1, 2012 · User-defined variables are session-specific. That is, a user variable defined by one client cannot be seen or used by other clients. They can be used in SELECT queries using …

  4. How do I declare and assign a variable on a single line in SQL

    How do I declare and assign a variable on a single line in SQL Asked 15 years, 4 months ago Modified 8 years, 4 months ago Viewed 184k times

  5. sql - Must declare the scalar variable - Stack Overflow

    Must declare the scalar variable "@year" That's because you are trying to run a bunch of code that includes BOTH the stored procedure execution AND the query below it (!).

  6. How to declare variable and use it in the same Oracle SQL script ...

    How can I declare a variable and reuse it in statements that follow such as in using it SQLDeveloper. Attempts Use a DECLARE section and insert the following SELECT statement …

  7. sql - Why is a variable declared inside IF statement created even …

    Apr 5, 2025 · In the first pass, SQL Server scans for local variables, ignoring other pieces of code, such as IF or WHILE statements. When it finds a DECLARE statement for a local variable, it …

  8. sql - Declare a variable in a PostgreSQL query - Stack Overflow

    How do I declare a variable for use in a PostgreSQL 8.3 query? In MS SQL Server I can do this:

  9. SELECT INTO a table variable in T-SQL - Stack Overflow

    Oct 1, 2010 · Got a complex SELECT query, from which I would like to insert all rows into a table variable, but T-SQL doesn't allow it. Along the same lines, you cannot use a table variable with …

  10. plsql - Declaring a variable and setting its value from a SELECT …

    DECLARE the_variable NUMBER; BEGIN SELECT my_column INTO the_variable FROM my_table; END; Make sure that the query only returns a single row: By default, a SELECT …