SQL Server使用Bulk Insert把一个文本导入到数据库
This is very common request recently – How to import CSV file into SQL Server? How to load CSV file into SQL Server Database Table? How to load comma delimited file into SQL Server? Let us see the solution in quick steps.
CSV stands for Comma Separated Values, sometimes also called Comma Delimited Values.
Create TestTable
USE TestData
GO
CREATE TABLE CSVTest
(ID INT,
FirstName VARCHAR(40),
LastName VARCHAR(40),
BirthDate SMALLDATETIME)
GO
Create CSV file in drive C: with name csvtest.txt with following content. The location of the file is C:\csvtest.txt
1,James,Smith,19750101
2,Meggie,Smith,19790122
3,Robert,Smith,20071101
4,Alex,Smith,20040202
Now run following script to load all the data from CSV to database table. If there is any error in any row it will be not inserted but other rows will be inserted.
BULK
INSERT CSVTest
from 'c:\csvtest.txt'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
--Check the content of the table.
SELECT *
from CSVTest
GO
--Drop the table to clean up database.
SELECT *
from CSVTest
GO
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
引自http://www.05112.com/Article/200908/26674.html
网站SQL注入漏洞全接触(高级篇)
文章整理发布:黑客风云 内容关注度:
291 更新时间:2009-8-15 6:36:47
看完入门篇和进阶篇后,稍加练习,破解一般的网站是没问题了。但如果碰到表名列名猜不到,或程序作者过滤了一些特殊字符,怎么提高注入的成功率?怎 ......
MySQL服务器包含一些其他SQL DBMS中不具备的扩展。注意,如果使用了它们,将无法把代码移植到其他SQL服务器。在某些情况下,你可以编写包含MySQL扩展的代码,但仍保持其可移植性,方法是用“/*... */”注释掉这些扩展。MySQL服务器能够解析并执行注释中的代码,就像对待其他MySQL语句一样,但其他SQL服务器将忽略 ......
參考: http://brightsky006.blog.163.com/blog/static/22583668200962195059485/
把SQL 2005的备份文件导入到SQL 2000
学习珍藏 2009-07-21 09:50 阅读616 评论0
字号: 大大 中中 小小
电脑上安装了SQL Server 2005,现在想换回SQL2000来, ......