sql BULK_INSERT_Demo.sql
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql BULK_INSERT_Demo.sql相关的知识,希望对你有一定的参考价值。
USE master;
CREATE DATABASE [TestDB]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'TestDB'
, FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\TestDB.mdf'
, SIZE = 4GB
, MAXSIZE = UNLIMITED
, FILEGROWTH = 4GB )
LOG ON
( NAME = N'TestDB_log'
, FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\TestDB_log.ldf'
, SIZE = 1GB
, MAXSIZE = 2048GB
, FILEGROWTH = 1GB )
GO
-- https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/recovery-models-sql-server
ALTER DATABASE TestDB SET RECOVERY SIMPLE WITH NO_WAIT;
GO
USE TestDB;
GO
IF OBJECT_ID('dbo.TableTest', 'U') IS NOT NULL
DROP TABLE dbo.TableTest;
GO
CREATE TABLE dbo.TableTest(
ActionDate datetime2(0),
ActionValue decimal(12,3),
IsFlag bit
);
GO
-- https://docs.microsoft.com/en-us/sql/t-sql/statements/bulk-insert-transact-sql
BULK INSERT TableTest
FROM 'D:\MyBigFile.csv'
WITH
( CODEPAGE = '65001',
DATAFILETYPE = 'char',
FIELDTERMINATOR = ',' ,
FIRSTROW = 2
);
GO
/*
MyBigFile.csv file content:
ActionDate,ActionValue,IsFlag
2017-10-19,1.000123,1
2017-10-19,2.100123,0
2017-10-19,3.000123,1
*/
以上是关于sql BULK_INSERT_Demo.sql的主要内容,如果未能解决你的问题,请参考以下文章
sql 2008和sql 2012的区别
sql [sql技巧]一些sql技巧#sql
sql 2008 r2 在sql 2008上兼容么
SQL基础
有大神知道,sql server 中如何批量执行sql语句吗?
pl sql developer怎么执行sql