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

Posted by sunilkes on 11/07/07 17:17

Hello

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]
@strfinalint as varchar(1000),
@startdate as datetime
@enddate as datetime

as

declare @insertcmd as varchar(2000)
declare @startdate as datetime
declare @enddate as datetime

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)
GO

It was working with the command

set @insertcmd = 'INSERT INTO OPENROWSET(''Microsoft.Jet.OLEDB.
4.0'',''Excel 8.0;Database=d:\MyFolder\' + @strfinalint + ';'',
''SELECT * FROM [Sheet1$]'') Select * from tbltest'

But I am struggling to include the WHERE part of it, I seem to have
problems making the variables work in this with appropriate quotation
marks !!

Thanks
Sunny

 

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

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