CREATE TABLE [dbo].[litSDO](
[litSDOId] [int] IDENTITY(1,1) NOT NULL,
[OrderId] [int] NULL,
[FSBId] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[TMR] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Qty] [int] NOT NULL,
[EventDate] [smalldatetime] NULL,
[JobNumber] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
File : (.txt)
"Order_ID","FSB_ID","TMR","Qty","EVENT_DATE","job_number"
2473887,"BOS","FJ780",1,2011-05-19 12:48:12,"G3191116"
2473888,"BOS","G377T",1,2011-05-19 12:48:14,"G3191131"
2473889,"BOS","HP592",1,2011-05-19 12:48:14,"G3191131"
2473926,"DC","28Y5M",1,2011-05-19 12:54:12,"G3191315"
I need to upload this into a SQL table and keepidentity. Also need to start the import at the 2nd line (ignoring the header)
Joshua HarrisPosted May 23, 2011, 10:45 PM
Pradeep ChandrakerPosted May 21, 2011, 4:31 PM
Joshua HarrisPosted May 21, 2011, 4:15 PM
Unfortunately this is still on SQL 2000 (business owned CSS) not IT supported and they will not take it the way it is. So 2000 is what I have to work with.
Just to clarify are you saying set the identity in the table as the last column?
Pradeep ChandrakerPosted May 21, 2011, 12:42 AM
Joshua HarrisPosted May 20, 2011, 10:45 PM
........build data table rows
using (SqlConnection cn = new SqlConnection(cs.AppSettings["ConnString"].ToString()))
{
cn.Open();
try
{
SqlBulkCopycopy = new SqlBulkCopy(cn);
{
copy.ColumnMappings.Add(0, 0);
copy.ColumnMappings.Add(1, 1);
copy.ColumnMappings.Add(2, 2);
.....etc....
copy.DestinationTableName = SqlBulkCopy copy = new SqlBulkCopy cn);"myTable"
copy.WriteToServer(dt);
}
}
Posted May 20, 2011, 10:42 PM
Keep all the values into excel. By using the data import /export wizard, select the source as excel , here you can mention the first row is the header and you can ignore it. After the mapping the destination database and table, by using the mapping option, you can enable identity insert as well.
Hope this helps you.