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 |
ac_786
Starting Member
2 Posts |
Posted - 2006-04-25 : 12:05:34
|
I am having an issue with the Bulk insert not being able to insert into a Temp (#) table. The user has been made the Bulk insert admin. and CAN BULK INSERT fine into a regular table. My issue is that I would like to use a #Tmp_table. The procedure fails on the Bulk insert statement with the following error message: "The current user is not the database or object owner of table '#TmpStage'. Cannot perform SET operation. ". Here is the procedure :CREATE PROCEDURE spDoBulkInsert(@FiletoLoad VARCHAR(200))ASBEGINDECLARE @Sql VARCHAR(2000)CREATE #TmpStage (Col1 INT, Col2 VARCHAR(20))--I simply create the Bulk insert statement here.SELECT @Sql = ' BULK INSERT #TmpStage ' + ' From ''' + @FiletoLoad + '''' + ' WITH (' + ' ROWS_PER_BATCH = 999999,' + ' BATCHSIZE = 999999,' + ' FIELDTERMINATOR = '','', ' + ' FIRSTROW = 2,' + ' ROWTERMINATOR = ''\n'',' + ' TABLOCK )' EXEC (@Sql)INSERT INTO TblRealTable (Col1, Col2) SELECT Col1, Col2 FROM #TmpStageEND |
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2006-04-25 : 23:57:35
|
instead of local use global temp table##tmpstageand be sure to drop afterwards--------------------keeping it simple... |
 |
|
|
|
|