Wednesday, July 27, 2011

Set AutoIncrement to "0"


USE NopNew;
  GO
  DBCC CHECKIDENT ("Nop_Picture", RESEED, 0);
  GO

//nopnew is the database name
// nop_picture is the table name

Friday, July 1, 2011

How to Store .CSV file in Sql Server


CREATE TABLE CSVTestNewTest
(
[Offer Ref] Nvarchar (255),
[Quote Ref] Nvarchar(100),
[Midwich Part] Nvarchar(200),
[Midwich Part Description] Nvarchar(200),
[Minimum] nvarchar(50),
[Qty] nvarchar(200),
[Free Part Description] nvarchar(max),
[Offer Description] nvarchar(max),
[Type] nvarchar(100),
[Available Qty] nvarchar(200)
)
GO

BULK
INSERT CSVTestNewTest
FROM 'D:\varun\Project Assets\Qb Assets\Qb Assets\Data Feed 30june11\data\free_parts.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO



Description: first of all create table of all the column available in excel or csv file. then with the bulk insert statement give the location where your excel or csv file is stored and exceute the query with syntax describe above.