diddydustin
Programmer
Hi guys,
I am trying to run the following code:
-- local variables
DECLARE @Worksheet AS varchar(255)
DECLARE @SQLString AS varchar(255)
DECLARE @RC int
DECLARE @server nvarchar(128)
DECLARE @srvproduct nvarchar(128)
DECLARE @provider nvarchar(128)
DECLARE @datasrc nvarchar(4000)
DECLARE @location nvarchar(4000)
DECLARE @provstr nvarchar(4000)
DECLARE @catalog nvarchar(128)
DECLARE @intQueID as int
SET @intQueID = 121
DECLARE @strFileName AS varchar(255)
SET @strFileName = '\\devweb\upload\AmazonQue\test_7_7_2005_9_32_12.xls'
-- local variable values
SET @Worksheet = 'Sheet1$'
BEGIN
-- Build insert string
--SET @SQLstring = 'INSERT ' + 'tblQueItem (chrISBN, intQueID, chrRecordStatus) SELECT ISBN, ' + @intQueID + ', "A" FROM ' + @ExcelSource + '...' + @Worksheet
--T @SQLstring = 'INSERT INTO tblQueItem (chrISBN, intQueID, chrRecordStatus) SELECT ISBN, ' + cast(@intQueID as varchar(128)) + ', "A" FROM ExcelSource...' + @Worksheet
SET @SQLstring = 'INSERT INTO tblQueItem
SELECT e.ISBN, ' + cast(@intQueID as varchar(128)) + ', "A"
FROM ExcelSource...' + @Worksheet + ' e
LEFT OUTER JOIN tblQueItem q
ON q.chrISBN = e.ISBN
WHERE isnull(q.chrISBN,"x") <> e.ISBN
GROUP BY e.ISBN'
END
-- Create the link
--EXEC sp_addlinkedserver @server = 'ExcelSource'
-- , @srvproduct = 'Microsoft Excel Workbook'
-- , @provider = 'Microsoft.Jet.OLEDB.4.0'
-- , @datasrc = @strFileName
-- , @provstr = 'Excel 5.0'
-- Set parameter values
SET @server = 'ExcelSource'
SET @srvproduct = 'Excel'
SET @provider = 'Microsoft.Jet.OLEDB.4.0'
SET @datasrc = @strFileName
SET @provstr = 'Excel 8.0'
EXEC @RC = [master].[dbo].[sp_addlinkedserver] @server, @srvproduct, @provider,
@datasrc, @location, @provstr, @catalog
EXEC sp_addlinkedsrvlogin 'ExcelSource', 'false', null, null, null
-- Load from the link to the table
EXEC (@SQLString)
-- Break the link
EXEC sp_dropserver 'ExcelSource', 'droplogins'
When I try to run the code, I get the following error:
(1 row(s) affected)
(1 row(s) affected)
(0 row(s) affected)
(1 row(s) affected)
(0 row(s) affected)
(1 row(s) affected)
Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.
[OLE/DB provider returned message: Unspecified error]
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0' IDBInitialize::Initialize returned 0x80004005: ].
I've checked various pages on Help and Support from Microsoft but it appears I cannot solve this problem. The version of SQL Server and the Jet database we are using is current. I believe all permissions are set correctly. I cannot seem to pinpoint why we are getting this error.
Can anyone point me in a direction I could go looking? I am stuck.
Thanks
Dustin
It seems I cannot get this to work no matter what I try. I've looked at
I am trying to run the following code:
-- local variables
DECLARE @Worksheet AS varchar(255)
DECLARE @SQLString AS varchar(255)
DECLARE @RC int
DECLARE @server nvarchar(128)
DECLARE @srvproduct nvarchar(128)
DECLARE @provider nvarchar(128)
DECLARE @datasrc nvarchar(4000)
DECLARE @location nvarchar(4000)
DECLARE @provstr nvarchar(4000)
DECLARE @catalog nvarchar(128)
DECLARE @intQueID as int
SET @intQueID = 121
DECLARE @strFileName AS varchar(255)
SET @strFileName = '\\devweb\upload\AmazonQue\test_7_7_2005_9_32_12.xls'
-- local variable values
SET @Worksheet = 'Sheet1$'
BEGIN
-- Build insert string
--SET @SQLstring = 'INSERT ' + 'tblQueItem (chrISBN, intQueID, chrRecordStatus) SELECT ISBN, ' + @intQueID + ', "A" FROM ' + @ExcelSource + '...' + @Worksheet
--T @SQLstring = 'INSERT INTO tblQueItem (chrISBN, intQueID, chrRecordStatus) SELECT ISBN, ' + cast(@intQueID as varchar(128)) + ', "A" FROM ExcelSource...' + @Worksheet
SET @SQLstring = 'INSERT INTO tblQueItem
SELECT e.ISBN, ' + cast(@intQueID as varchar(128)) + ', "A"
FROM ExcelSource...' + @Worksheet + ' e
LEFT OUTER JOIN tblQueItem q
ON q.chrISBN = e.ISBN
WHERE isnull(q.chrISBN,"x") <> e.ISBN
GROUP BY e.ISBN'
END
-- Create the link
--EXEC sp_addlinkedserver @server = 'ExcelSource'
-- , @srvproduct = 'Microsoft Excel Workbook'
-- , @provider = 'Microsoft.Jet.OLEDB.4.0'
-- , @datasrc = @strFileName
-- , @provstr = 'Excel 5.0'
-- Set parameter values
SET @server = 'ExcelSource'
SET @srvproduct = 'Excel'
SET @provider = 'Microsoft.Jet.OLEDB.4.0'
SET @datasrc = @strFileName
SET @provstr = 'Excel 8.0'
EXEC @RC = [master].[dbo].[sp_addlinkedserver] @server, @srvproduct, @provider,
@datasrc, @location, @provstr, @catalog
EXEC sp_addlinkedsrvlogin 'ExcelSource', 'false', null, null, null
-- Load from the link to the table
EXEC (@SQLString)
-- Break the link
EXEC sp_dropserver 'ExcelSource', 'droplogins'
When I try to run the code, I get the following error:
(1 row(s) affected)
(1 row(s) affected)
(0 row(s) affected)
(1 row(s) affected)
(0 row(s) affected)
(1 row(s) affected)
Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.
[OLE/DB provider returned message: Unspecified error]
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0' IDBInitialize::Initialize returned 0x80004005: ].
I've checked various pages on Help and Support from Microsoft but it appears I cannot solve this problem. The version of SQL Server and the Jet database we are using is current. I believe all permissions are set correctly. I cannot seem to pinpoint why we are getting this error.
Can anyone point me in a direction I could go looking? I am stuck.
Thanks
Dustin
It seems I cannot get this to work no matter what I try. I've looked at