笔记255 SQLSERVER使用SELECT * INTO 复制数据或者只复制结构 2013-4-29
笔记255 SQLSERVER使用SELECT * INTO 复制数据或者只复制结构 2013-4-29
1 --SQLSERVER使用SELECT * INTO 复制数据或者只复制结构 2013-4-29 2 USE [tempdb] 3 GO 4 CREATE TABLE #AreaA 5 ( 6 AreaID INT NOT NULL , 7 ParentID NVARCHAR(100) , 8 Area_index NVARCHAR(100) 9 ) 10 GO 11 INSERT INTO [#AreaA] 12 ( [AreaID] , 13 [ParentID] , 14 [Area_index] 15 ) 16 SELECT 100,NULL,N'中国' UNION ALL 17 SELECT 101,'北京市 100',',100,' UNION ALL 18 SELECT 102,'海淀区 101','100,101,' 19 20 SELECT * FROM [#AreaA] 21 22 SELECT * FROM [#AreaA] where AreaID = 101 OR [Area_index] like '%,101,%' 23 24 SELECT * INTO #keep FROM [#AreaA] WHERE 1 = 2 --WHERE 条件为假,所以只能复制结构 25 SELECT * INTO #AreaB FROM [#AreaA] WHERE 1 = 1 --WHERE条件为真,所以复制数据和结构 26 27 SELECT * FROM [#keep] 28 SELECT * FROM [#AreaB]