About 183,000 results
Open links in new tab
  1. sql - Creating an index on a table variable - Stack Overflow

    May 20, 2009 · In addition to the methods of adding constraint based indexes discussed below SQL Server 2014 also allows non unique indexes to be specified directly with inline syntax on table variable declarations. Example syntax for that is below. /*SQL Server 2014+ compatible inline index syntax*/ DECLARE @T TABLE ( C1 INT INDEX IX1 CLUSTERED, /*Single ...

  2. How to declare a table variable with existing data in sql server

    Mar 19, 2020 · @JeroenMostert yeah I know that, but the reason I'm doing this way is because it is going to be used many many times for tens of queries so I want to be able to easily change it for all. the reason I asked the question was for learning purpose mostly

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

    Oct 1, 2010 · Step 3: Declare a table Variable to hold temp table data. declare @tblOm_Variable table( Name Varchar(100), Age int, RollNumber bigint ) Step 4: select value from temp table and insert into table variable. insert into @tblOm_Variable select * from #tblom_temp Finally value is inserted from a temp table to Table variable . Step 5: Can Check ...

  4. What's the difference between a temp table and table variable in …

    Aug 26, 2008 · Table variable: But the table variable involves the effort when we usually create the normal tables. Temp table: Temp table result can be used by multiple users. Table variable: But the table variable can be used by the current user only. Temp table: Temp table will be stored in the tempdb. It will make network traffic.

  5. sql - A table name as a variable - Stack Overflow

    For static queries, like the one in your question, table names and column names need to be static. For dynamic queries, you should generate the full SQL dynamically, and use sp_executesql to execute it. Here is an example of a script used to compare data between the same tables of different databases: Static query:

  6. sql - Update table variable - Stack Overflow

    Mar 28, 2016 · Sql server will not treat the % inside the table variable as a wildcard, it will treat it as a part of the string. However, there are ways around that, if you can change the table variable. However, there are ways around that, if you can change the table variable.

  7. How to use table variable in a dynamic sql statement?

    On SQL Server 2008+ it is possible to use Table Valued Parameters to pass in a table variable to a dynamic SQL statement as long as you don't need to update the values in the table itself. So from the code you posted you could use this approach for …

  8. "Must declare the table variable "@name"" in stored procedure

    The issue is that you're mixing up dynamic SQL with non-dynamic SQL. Firstly - the reason it works when you put NULL into @NotNeededWPRNs is because when that variable is NULL, your @ProductsSQL becomes NULL. WHat you need to do is either make your @PropsIDs table a non-table variable and either a temporary table or a physical table.

  9. Incorrect syntax error on select statement from SQL Server using …

    Oct 24, 2012 · The Declare @TableName syntax is for table variables, not temp tables, and I'm thinking that the @Table variable is out of scope when the EXEC occurs. – David W Commented Oct 24, 2012 at 16:14

  10. How do I drop table variables in SQL-Server? Should I even do this?

    Temp table variable is saved to the temp.db and the scope is limited to the current execution. Hence, unlike dropping a Temp tables e.g drop table #tempTable, we don't have to explicitly drop Temp table variable @tempTableVariable. It is automatically taken care by the sql server. drop table @tempTableVariable -- Invalid

Refresh