You are here: Re: Using variable in Stored procedure - help! « MsSQL Server « IT news, forums, messages
Re: Using variable in Stored procedure - help!

Posted by sunilkes on 11/09/07 10:59

Erland,

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.

Sorry, but I am not too good at this.

Thanks
Sunil

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация