Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
kd12345
Starting Member
12 Posts |
Posted - 2008-01-08 : 11:21:04
|
I've been trying to use the parameters passed to a stored procedure then using hard codeded value for the OPENDATASOURCE function. I keep getting Incorrect syntax near '+'here is my code.DECLARE cursor1 CURSOR FOR SELECT distinct RTRIM(OPRID) FROM TEMP_TABLEOPEN cursor1declare @OPRID1 varchar(18) FETCH NEXT FROM cursor1 INTO @OPRID1;WHILE (@@FETCH_STATUS <> -1) BEGINinsert into OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source="c:\Book1_01-08-08.xls";Extended properties=Excel 8.0')...+ @OPRID1 + '$'(col1, col2, col3) select col1, col2, col3 from TEMP_TABLE WHERE OPRID = @OPRID1end FETCH NEXT FROM cursor1 INTO @OPRID1; CLOSE cursor1DEALLOCATE cursor1it doesnot like the Opendatasource(....)...+ @OPRID1 + '$'For example @OPRID1 is passing "zzz1' and i want to insert the value in "zzz1' excel tab. Excel file has "zzz1" tab.Thanks. |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-01-08 : 11:24:24
|
nope. that doesn't work.you'll have to do your insert with dynamic sqlexec(' insert into ... ' + @oprid1 + '...')_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com <- new version out |
 |
|
|
|
|