Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 stored procedure error?

Author  Topic 

jcb267
Constraint Violating Yak Guru

291 Posts

Posted - 2009-04-16 : 22:27:17
The stored procedure that follows ran fine, no errors. However, when I looked in the table, there was no data there.

USE [Hospital_Compare];
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

/******************************************************
Object: StoredProcedure import csv to HQI_FTNT
Script Date: 04/12/2009
JCB
******************************************************/

CREATE PROCEDURE importcsvfile
AS
BULK INSERT dbo.HQI_FTNT FROM 'C:\Users\John & Tanya\Documents\John\Hospital Compare Hospital_flatfiles\dbo_vwHQI_FTNT.csv'
WITH
(DATAFILETYPE = 'char',
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n');
GO

The message box said that the command completed successfully but when I look at the table, there is no data in it. Do you know why?
Here is one record from the .csv file:
Footnote Footnote Text
1 The number of cases is too small (<25) to reliably tell how well a hospital is performing

Rajesh Jonnalagadda
Starting Member

45 Posts

Posted - 2009-04-17 : 03:21:49
Hi,
Your data shows that, fields are tab seperated not comma seperated

so use FIELDTERMINATOR = '\t' instead of FIELDTERMINATOR = ','

Try this,

---- STEP 1
USE [Hospital_Compare];
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

/******************************************************
Object: StoredProcedure import csv to HQI_FTNT
Script Date: 04/12/2009
JCB
******************************************************/

CREATE PROCEDURE importcsvfile
AS
BULK INSERT dbo.HQI_FTNT FROM 'C:\Users\John & Tanya\Documents\John\Hospital Compare Hospital_flatfiles\dbo_vwHQI_FTNT.csv'
WITH
(DATAFILETYPE = 'char',
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\n');
GO

---- STEP 2
EXEC importcsvfile


Rajesh Jonnalagadda
[url="http://www.ggktech.com
"]GGK TECH[/url]
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-17 : 03:35:09
Duplicate post
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=123835



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -