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 |
|
truthseeker
Starting Member
15 Posts |
Posted - 2010-09-27 : 14:04:31
|
| Currently, I'm using a stored procedure that imports an excel file to sql server like so:DECLARE @sqlimport nvarchar(1000)DECLARE @filename nvarchar(100)SET @filename = 'D:\test.xls'SET @sqlimport = 'SELECT * INTO #Test1 FROM OPENROWSET(''Microsoft.Jet.OLEDB.4.0'',''Excel 8.0;Database='+@filename+';HDR=NO,IMEX=1'',''SELECT * FROM [Sheet1$]'')'EXEC (@sqlimport) This returns the result and I can see that it returned:(809 row(s) affected)However when I select it immediately right after the exec command:SELECT * FROM #Test1I getMsg 208, Level 16, State 0, Line 15Invalid object name '#Test1'.What's happening and how do I solve this?Thanks! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
truthseeker
Starting Member
15 Posts |
Posted - 2010-09-27 : 14:52:42
|
| Thanks! That helped a lot! I decided to use a global temp table and it works great! |
 |
|
|
|
|
|