Αποτελέσματα Αναζήτησης
--DECLARE TABLE NAME VARIABLE DYNAMICALLY DECLARE @table_name varchar(max) SET @table_name = (SELECT 'TEST_' + DATENAME(YEAR,GETDATE()) + UPPER(DATENAME(MONTH,GETDATE())) ) --DROP THE TABLE IF IT ALREADY EXISTS IF EXISTS(SELECT name FROM sysobjects WHERE name = @table_name AND xtype = 'U') BEGIN EXEC('drop table ' + @table_name) END --CREATES ...
20 Μαΐ 2019 · A table variable is a local variable that has some similarities to temp tables. Table variables are created via a declaration statement like other local variables. Like other local variables, a table variable name begins with an @ sign. However, its declaration statement has a type of table.
How to declare table variables. To declare a table variable, you use the DECLARE statement as follows: DECLARE @table_variable_name TABLE (. column_list. ); Code language: SQL (Structured Query Language) (sql) In this syntax, you specify the name of the table variable between the DECLARE and TABLE keywords.
3 Δεκ 2019 · The table variable is a special type of the local variable that helps to store data temporarily, similar to the temp table in SQL Server. In fact, the table variable provides all the properties of the local variable, but the local variables have some limitations, unlike temp or regular tables.
4 Αυγ 2014 · DECLARE @sql AS VARCHAR(MAX) SET @sql = 'Select * From ' + @yourTableNameVariable. EXEC(@sql) ORACLE source. sql_stmt := 'Select * From ' || yourTableNameVariable; EXECUTE IMMEDIATE sql_stmt; MySQL source. SET @s = CONCAT('SELECT * FROM ',@yourTableNameVariable); PREPARE stmt FROM @s;
16 Οκτ 2019 · The table variable is a special data type that can be used to store temporary data similar to a temporary table. The syntax for the table variable looks similar to defining a new table using the CREATE TABLE statement: In the above query, we specified a table variable using the DECLARE and TABLE keyword.
Declare a Transact-SQL variable. The DECLARE statement initializes a Transact-SQL variable by: Assigning a name. The name must have a single @ as the first character. Assigning a system-supplied or user-defined data type and a length. For numeric variables, a precision and scale are also assigned.