海量数据的导入导出

bulk insert dbo.demotable from 'D:\code.txt'
 with (
 DATAFILETYPE = 'char',
 FIELDTERMINATOR = ',',
 ROWTERMINATOR = '\n',
 --FIRSTROW=100,
 --LASTROW=110,
 ROWS_PER_BATCH=5000000000 )
 
 alter procedure AddLotData
 @StartRow int,
 @EndRow int,
 @Rows int,
 @URL nvarchar(100)
 as
 declare @sql nvarchar(2000)
 set @sql='
 with (
 DATAFILETYPE = ''char'',
 FIELDTERMINATOR = '','',
 ROWTERMINATOR = ''\n'',
 FIRSTROW='+convert(nvarchar,@StartRow)+','+'
 LASTROW='+convert(nvarchar,@EndRow)+',
 ROWS_PER_BATCH='+convert(nvarchar,@Rows)+' ) '
 print @sql
 exec sp_executesql @sql
 
 
 --==========
 exec AddLotData
 
 
 USE [demo]
 GO
 /****** 对象:  Table [dbo].[demotable]    脚本日期: 09/11/2009 17:32:58 ******/
 SET ANSI_NULLS ON
 GO
 SET QUOTED_IDENTIFIER ON
 GO
 SET ANSI_PADDING ON
 GO
 CREATE TABLE [dbo].[demotable](
  [id] [decimal](24, 0) IDENTITY(1,1) NOT NULL,
  [info] [varchar](max) NULL,
  CONSTRAINT [PK_demotable] PRIMARY KEY CLUSTERED
 (
  [id] ASC
 )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
 ) ON [PRIMARY]
 
 GO
 SET ANSI_PADDING OFF
 
 
 truncate table dbo.demotable
 
 select top 100 * from demotable
 
 create procedure BindInfo
 as
 select count(*) from demotable
 
 
 
 EXEC master.dbo.sp_configure 'show advanced options', 1
 
 RECONFIGURE
 
 EXEC master.dbo.sp_configure 'xp_cmdshell', 1
 
 RECONFIGURE
 
 
 
 EXEC xp_cmdshell 'bcp "SELECT * FROM demo.dbo.demotable" queryout D:\data.txt -c -t, -S APASS-F992C009E -U sa -P sa'
 
 
 EXEC master..xp_cmdshell 'bcp "Select * from demo..demotable" queryout c:\DT.txt -c -Sservername -Usa -Ppassword'
 
 
 EXEC master..xp_cmdshell 'bcp "Select * from demo..demotable" queryout D:\DT.txt -c -t, -S APASS-F992C009E -U sa -P sa'
 
 
 bulk select * from 'D:\wl_ln_boxcode.txt'
 with (
 DATAFILETYPE = 'char',
 FIELDTERMINATOR = ',',
 ROWTERMINATOR = '\n',
 FIRSTROW=7000000,
 LASTROW=7000500
  )
 
 
 Declare @I int
 
 Set @I = 0
 
 Begin Tran
 
 InsertData:
 
 Insert into dbo.demotable(info,remark) values (@I, @I)
 
 Set @I = @I + 1
 
 If @I < 100000
 
     Goto InsertData
 
 Commit Tran
 
 
 
 create proc ADDdemoInfo
 @info varchar(max)
 as
 insert into dbo.demotable(info)
 values(@info)
 
 create proc DelDemoinfo
 @id int
 as
 
 create proc QueryInfo
 @Info varchar(50)
 as
 declare @sql nvarchar(2000)
 
 print @sql
 exec SP_executesql @sql
 
 create proc UpdateInfo
 @id int,
 @info varchar(50)
 as
 
 create proc BindUpdate
 @id int
 as
 
 
 
 create procedure ClearAll
 as
 truncate table dbo.demotable

posted on 2010-12-23 10:12  青春的虎子  阅读(191)  评论(0)    收藏  举报

导航