Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

My Experiments with SQLServer
Browse by Tags · View All
SQLServer 126
SQLServer 2008 R2 91
SQLServer 2008 86
SQLServer 2005 82
SQL 60
Database 59
Sql And Me 57
Tips & Tricks 28
SQL Server 27
SQL FAQ 26

Archive · View All
May 2011 25
June 2011 21
July 2011 21
August 2011 19
April 2011 16
January 2013 4
May 2012 3
April 2012 3
October 2011 3
February 2013 2

Vishal Gajjar's Blog

TSQL – Import Data Using BULK INSERT

Apr 26 2011 8:35AM by Vishal Gajjar   

We can populate a table using a dump of data available as a text file. You can also import data from various type of files including CSV and raw file into SQL. In the example we’ll look at how to import data from a Text file into SQL Table.

For this example, I have a Text file ProductList.txt as my input data.

We use a BULK INSERT statement to import data from a text file. If I need to import data to a Table called ProductList in the database, the table must exist in the database. For simple BULK INSERTs the input data must match the data types and number of columns in the target table. I have created a Table using the same structure as the INPUT file:

— © 2011 – Vishal (http://SqlAndMe.com)
CREATE TABLE [dbo].[ProductList]
(
      [ProductID] INT IDENTITY(1,1) NOT NULL,
      [Name] NVARCHAR(50) NOT NULL,
      [ProductNumber] NVARCHAR(50) NOT NULL,
      [StandardCost] MONEY NOT NULL
)

Once, the table is created, you can use BULK INSERT to import data from the text file as below:

— © 2011 – Vishal (http://SqlAndMe.com)
BULK INSERT ProductList
FROM 'C:\ProductList.txt'
WITH
(
      FIELDTERMINATOR =',',
      ROWTERMINATOR = '\n'
)

The ROWTERMINATOR and FIELDTERMINATOR are what they say. for example, if you are using any other symbol for separating columns then, you need to specify that as FIELDTERMINATOR. Same way for ROWTERMINATOR.

The output of the above statement will be:

(11 row(s) affected)

There are other options available for BULK INSERT, For a full list of options refer BULK INSERT (Transact-SQL).

Hope This Helps! Cheers!


Republished from Sql&Me [31 clicks].  Read the original version here [32134 clicks].

Vishal Gajjar
46 · 4% · 1276
0
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]