![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am a newbie to this, so I would appreciate any help, I am struggling to get this to work CREATE PROCEDURE [dbo].[sp_test] |
|
set @insertcmd = 'INSERT INTO OPENROWSET(''Microsoft.Jet.OLEDB. 4.0'',''Excel 8.0;Database=d:\MyFolder\' + @strfinalint + ';'', ''SELECT * FROM [Sheet1$]'') Select * from tbltest WHERE S_Date Between' + @startdate + 'AND' + @enddate EXEC (@insertcmd) |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Thanks, this gets me closer to what I want to achieve, but because of the @insertcmd being a varchar or nvarchar, I am having problems filtering the dates. CREATE PROCEDURE [dbo].[USP_Test] @strfinalint as varchar(1000), @startdate as datetime, @enddate as datetime as declare @insertcmd as nvarchar(2000) set @insertcmd = 'INSERT INTO OPENROWSET(''Microsoft.Jet.OLEDB. 4.0'',''Excel 8.0;Database=D:/MyDrive/' + @strfinalint + ';'', ''SELECT * FROM [Sheet1$]'') Select * from VwStaff WHERE S_Date Between '''+ @startdate + ''' AND '''+ @enddate + ''' ' EXEC (@insertcmd) GO Am I doing something wrong? I tried using the @PARAMS but it does not seem to work, |
|
so I tried the above, and now it tells me Syntax error converting datetime from character string. |
![]() |
| Thread Tools | |
| Display Modes | |
| |