Hi,
I'm currently having a problem with an application I'm writing that imports data from a number of sources (Excel spreadsheets), then performs calculations on this imported data.
The problem I'm having is that the code I'm using to import the data into a sql table (which is automatically created by this code) is setting fields that should contain Real values to type nvarchar. This means that when I try to put the value into a field of type Real it breaks. The trouble is, I can't put it into a field of type varchar as then I can't perform calculations on the data. I've tried using "convert(real, value)" but it just says that it can't convert from varchar to real.
Can anyone suggest a workaround for this?
For information, the code I'm using to import the spreadsheet into the temporary table is:
SET @strSQL = 'SELECT * INTO [' + @target + '] FROM OPENROWSET(''Microsoft.Jet.OLEDB.4.0'', ''Excel 8.0;Database=' + @filename + ';HDR=YES;IMEX=1'', ''SELECT * FROM [' + @worksheet + '$]'')'
exec sp_executesql @strSQL
I'm currently having a problem with an application I'm writing that imports data from a number of sources (Excel spreadsheets), then performs calculations on this imported data.
The problem I'm having is that the code I'm using to import the data into a sql table (which is automatically created by this code) is setting fields that should contain Real values to type nvarchar. This means that when I try to put the value into a field of type Real it breaks. The trouble is, I can't put it into a field of type varchar as then I can't perform calculations on the data. I've tried using "convert(real, value)" but it just says that it can't convert from varchar to real.
Can anyone suggest a workaround for this?
For information, the code I'm using to import the spreadsheet into the temporary table is:
SET @strSQL = 'SELECT * INTO [' + @target + '] FROM OPENROWSET(''Microsoft.Jet.OLEDB.4.0'', ''Excel 8.0;Database=' + @filename + ';HDR=YES;IMEX=1'', ''SELECT * FROM [' + @worksheet + '$]'')'
exec sp_executesql @strSQL