UKmedia
Programmer
- Nov 2, 2002
- 90
I have the following script:
but sometimes the
might not always contain data so if there is no data how can I tell it to just carry on with the script at the moment I get error:
Msg 110, Level 15, State 1, Line 23
There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
UKmedia productions
Code:
drop table import_temp
CREATE TABLE import_temp
([col1] [float] NULL,
[col2] [float] NULL,
[col3] [float] NULL)
BULK INSERT import_temp FROM 'C:\test\tilldata\2100200850.csv' WITH (FIELDTERMINATOR = ',', FIRSTROW = 2)
declare @f1 float
declare @f2 float
declare @f3 float
declare @f4 float
declare @f5 float
set @f1 = (select col3 from import_temp where col1 = 1)
set @f2 = (select col3 from import_temp where col1 = 2)
set @f3 = (select col3 from import_temp where col1 = 4)
set @f4 = (select col3 from import_temp where col1 = 5)
set @f5 = (select col3 from import_temp where col1 = 27)
INSERT INTO tblgardiff_50
([net_sales]
,[gross_sales]
,[cash_in_draw]
,[cards_in_draw])
VALUES
(@f1
,@f2
,@f3
,@f4
,@f5)
Code:
set @f1 = (select col3 from import_temp where col1 = 1)
Msg 110, Level 15, State 1, Line 23
There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
UKmedia productions