by: ALBERT ANTHONY D. GAVINO
Using BULK INSERT statement in MS SQL Server 2008 helps in importing data files from other sources such as excel, txt into your TABLES in MS SQL Server.
Create a new table in your MS SQL Server
Open SQL Server Management Studio
Select an Instance
Right click Databases>Create a Database
and name the Database as NBA_PLAYERS
with a table name: Contacts
Create the fields as follows:
IDNO (int, not null)
Lastname (varchar(50), not null)
Firstname (varchar(50), not null)
Create a text file on your C: folder with the following records
101, juan, delacruz
102, michael, jordan
103, kobe, bryant
and save it as a txt file
use the code as follows:
BULK INSERT Contacts FROM 'c:\sample\sample.txt'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n"
)
GO
To view your Appended table
SELECT * FROM Contacts
Using BULK INSERT statement in MS SQL Server 2008 helps in importing data files from other sources such as excel, txt into your TABLES in MS SQL Server.
Create a new table in your MS SQL Server
Open SQL Server Management Studio
Select an Instance
Right click Databases>Create a Database
and name the Database as NBA_PLAYERS
with a table name: Contacts
Create the fields as follows:
IDNO (int, not null)
Lastname (varchar(50), not null)
Firstname (varchar(50), not null)
Create a text file on your C: folder with the following records
101, juan, delacruz
102, michael, jordan
103, kobe, bryant
and save it as a txt file
use the code as follows:
BULK INSERT Contacts FROM 'c:\sample\sample.txt'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n"
)
GO
To view your Appended table
SELECT * FROM Contacts
Tidak ada komentar:
Posting Komentar