August 11, 2010 at 7:07 am
Hi All,
How to insert data from a text file to SQL Serevr 7.0 table, using BCP utility.
Comma is a sperator for columns.
Thank You.
Regards,
Raghavender Chavva
August 11, 2010 at 12:12 pm
K . . . I'll bite . . .
BCP T-SQL reference . . .
http://msdn.microsoft.com/en-us/library/aa174646(SQL.80).aspx
Or . . .
Bulk insert may what you're looking for . . .
http://msdn.microsoft.com/en-us/library/ms188365.aspx
And . . . you'll probably need to read this too . . . "Creating a format file"
http://msdn.microsoft.com/en-us/library/ms191516.aspx
i.e.
CREATE TABLE [dbo].[tablename] (
[col1] [char] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[col2] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[col3] [char] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[col4] [char] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
BULK INSERT [tablename]
FROM '<driveletter>:\<path to file>\<filename>.<ext>'
WITH
(
FORMATFILE = '<driveletter>:\<path to FORMAT file>\<FORMAT File filename>.fmt'
)
Free Expert Advice . . .
http://xkcd.com/627/
Mark
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply