ALTER TABLE dbo. P_zpromotion_doc_items_temp ALTER COLUMN Mcrank varchar (20);
Method One: Use TestDB
--Creating a local temporary table create table #tmpStudent (Tid int,name varchar (), age int)
INSERT into #tmpStudent values (' Xiaowang ', 25)
SELECT * FROM #tmpStudent
--Create a local temporary table another way of writing select * into #tmpStudent from student
SELECT * FROM #tmpStudent
Method Two: Create table tempdb. mytemptable (Tid int)--You can write this with a corresponding permission
Delete tables: Drop table #tmpStudent
SQL temporary table usage Summary 1, creation Method: Method One: Create table temptablename or select [Field 1, Field 2,...,] into Temptablename from table method two: Create Tabl e tempdb. mytemptable (Tid int) Description: (1), the temporary table is actually placed in the database tempdb in a user table, (2), temptablename must have "#", "#" can be one or two, with # (local) or # # (global) Start of the table, This kind of table exists during the session, and the session end is deleted automatically; (3), if created without the # or # #开头, and tempdb. TempTable to name it, the table can persist until the database is restarted. 2. Manually delete the drop table Temptablename Description: The drop TABLE statement explicitly drops the temporary table, otherwise the temporary table will be automatically dropped by the system when it exits its scope: (1), when the stored procedure completes, the local temporary table created in the stored procedure is automatically dropped. This table can be referenced by all nested stored procedures that are executed by the stored procedure that created the table. However, the process calling the stored procedure that created this table cannot refer to this table, (2), all other local temporary tables are automatically dropped at the end of the current session, and (3) the global temporary table is automatically dropped when the session that created the table ends and other tasks stop referencing them. The association between a task and a table is persisted only within the lifetime of a single Transact-SQL statement. In other words, when the session that created the global temporary table ends, the last Transact-SQL statement referencing this table is finished and the table is automatically dropped.
SQL Modify table structure, temp table application