Question

I'm trying to insert data from an xlsx file into my temporal table. I've also tried with a real table, but it throws me the following error:

(0 rows affected)

I'm pretty sure my error is in the bulk insert part, because when I run just that part it throws me the same error.

This is the statement I am using to insert the data:

IF OBJECT_ID('tempdb..#stats_ddl') is not null DROP TABLE #stats_ddl 
GO
CREATE TABLE #stats_ddl ([Fecha] varchar(50),
[Descripción] varchar(max),
[Depósitos] varchar(50),
[Retiros] varchar(50),
[Saldo] varchar(50));
Go 

bulk insert mydb.dbo.#stats_ddl
from 'C:\some\where\myfile\is\file.xlsx'
with (          firstrow = 14,                    
            FIELDTERMINATOR = '\t',
            ROWTERMINATOR = '\n')

I am receiving this error:

Database name 'mydb' ignored, referencing object in tempdb.

What issues am I facing?

Was it helpful?

Solution

You cannot specify a database name, or schema name, when using a #temporary table.

Remove the # from the name of the stats_ddl table, and you'll see it works.

If you want to insert the rows into a temporary table, then remove the reference to the database name:

IF OBJECT_ID('tempdb..#stats_ddl') is not null DROP TABLE #stats_ddl 
GO
CREATE TABLE #stats_ddl ([Fecha] varchar(50),
[Descripción] varchar(max),
[Depósitos] varchar(50),
[Retiros] varchar(50),
[Saldo] varchar(50));
Go 

bulk insert #stats_ddl
from 'C:\some\where\myfile\is\file.xlsx'
with (          firstrow = 14,                    
            FIELDTERMINATOR = '\t',
            ROWTERMINATOR = '\n')
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top