DECLARE @a INTDECLARE aaa CURSOR for select columnID from LNDB_COLUMN_INFO where columnID BETWEEN 223899 AND 224003OPEN aaaFETCH next from aaa into @aWHILE @@fetch_status=0BEGINprint @aupdate LNDB_COLUMN_INFO SET columnID=@a-223910 where columnID=@aF…
SqlServer循环语句 declare @i int set @i =1 while(@i<5) begin set @i = @i+1 insert into text(id,name) values('1','王麻子') end SqlServer批量倒数据 如果两张表字段相同的话: insert into text1 select * from text如果两张表字段不同的话: insert into text1(fid,fname,fage...) select fid,fnam…
DECLARE @tablename VARCHAR(30),@sql VARCHAR(500)DECLARE cur_delete_table CURSOR READ_ONLY FORWARD_ONLY FORSELECT name FROM sysobjects WHERE name LIKE 'PUB%' AND type='U'OPEN cur_delete_tableFETCH NEXT FROM cur_delete_table INTO @tablenameWHILE @@FETC…
1.游标的状态,游标的开启游标的选择都是需要注意的. USE [ccnu] GO /****** Object: StoredProcedure [dbo].[P_ADD_DATA_XSBLHYCQK] Script Date: 2015/2/13 10:32:46 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author:…
USE [DB_JP_BaseInfo00] GO /****** Object: StoredProcedure [dbo].[sp_wx_getAppointmentInfo_Str] Script Date: 03/22/2016 14:48:24 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Auth…
标签:SQL SERVER/MSSQL SERVER/数据库/DBA/表分区 概述 在很多业务场景下我们需要对一些记录量比较大的表进行分区,同时为了保证性能需要将一些旧的数据进行归档.在分区表很多的情况下如果每一次归档都需要人工干预的话工程量是比较大的而且也容易发生纰漏.接下来分享一个自己编写的自动归档分区数据的脚本,原理是分区表和归档表使用相同的分区方案,循环利用当前的文件组. 一.创建测试数据 ----01创建文件组 USE [master] GO ALTER DATABASE [chenm…