Skip to main content

Import CSV File Into SQL Server [solved]

CSV stands for Comma Separated Values, sometimes also called Comma Delimited Values.
Create TestTable
USE TestData
GO
CREATE TABLE CSVTest(ID INT,FirstName VARCHAR(40),LastName VARCHAR(40),BirthDate SMALLDATETIME)GO
Create CSV file in drive C: with name sweetest. text with the following content. The location of the file is C:\csvtest.txt
1,James,Smith,19750101
2,Meggie,Smith,19790122
3,Robert,Smith,20071101
4,Alex,Smith,20040202
Now run following script to load all the data from CSV to database table. If there is any error in any row it will be not inserted but other rows will be inserted.
BULK
INSERT 
CSVTestFROM 'c:\csvtest.txt'WITH(FIELDTERMINATOR = ',',ROWTERMINATOR = '\n')GO--Check the content of the table.SELECT *FROM CSVTest
GO
--Drop the table to clean up database.DROP TABLE CSVTest
GO

Comments

Popular posts from this blog

List of categories of awesome effects css3 and javascript and Video Players

Here is the list of categories of awesome effects css3    Creative Link Effects  http://tympanus.net/Development/CreativeLinkEffects/ Website with video Player http://www.videojs.com/ http://www.w3schools.com/html/html5_video.asp http://dev.opera.com/articles/html5-video-flash-fallback-custom-controls/ Website with video on home page http://www.bienvillecapital.com/ http://www.theqcamera.com/ Creative Shapes pure css http://codepen.io/rachel_web/pen/pjzowB Create your own css 3 styles effect http://www.createcss3.com/ http://matthewlein.com/ceaser/ Create css for Sprite Images (Retina Friendly) http://www.spritecow.com/ http://spriteme.org/ Creaive and best websites  http://interactivewall.ru http://www.gsconto.com/chronicles/how-it-all-began.html http://www.fusionessence.com/ http://www.designzzz.com/ http://hverdagsreisen.no/  (best) HTML 5 Unicode character codes http://unicode-table.com/en/#003C Progress bar  h...

By pass single quote or special character in ck editor or fck editor in any language

By pass single quote or special character in ck editor or fck editor in any language like asp.net , php etc   whenever we are using ckeditor or fckeditor we are able to pass the data successfully but if single quote  '  or symbols like '|>|<|\\+ is present in our content then it will not save the data I search a lot for the solution of this topic.  Every post is provide some rumors but finally after using ck editor for long time, i found the solution. so friends now you can pass any type of data in fckeditor or ck editor  ------------------------------------------------------------------------------------------------------------------------ AdditionalNumericEntities With this setting, you can define a set of characters which will be translated to their relative numeric entities in the output HTML. This is quite useful if you don't want single quotes (') to be inserted in the text (being transformed to ′):...

(Solved) Failure sending mail in Godaddy Server

(Solved) Failure sending mail in Godaddy Server I know that this is an old thread.  At the same time, I worked on this problem for two weeks.  I wish that I had the final answer a couple of weeks ago! If you have shared hosting at GoDaddy.com, you need to use these credentials WHILE your are developing your application: In the namespaces you have to add using System.Net.Mail; or if you are not using any .cs file the you can insert namespace as <% @ Import Namespace ="System.Net.Mail" %> //for mail(from,to,subject,message) MailMessage msg = new MailMessage("frommailid@yourdomain.com", " tomailid@yourdomain.com ", "hello" , "your message"); SmtpClient smtp = new SmtpClient (); smtp . Host = "smtpout.secureserver.net" ; // Only works locally (development time) smtp . EnableSsl = false ; smtp . UseDefaultCredentials = false ; smtp . Credentials = new System . Net . NetworkCredential ( "...