bcpandas icon indicating copy to clipboard operation
bcpandas copied to clipboard

Writing to local temp tables

Open TabLand opened this issue 1 year ago • 1 comments

I kept getting this error when trying to write to a local temp table:

SQLState = S0002, NativeError = 208
Error = [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name '#MY_LOCAL_TEMP_TABLE'

These tables only are only meant to exist for as long as the connection is active so writing to a local temporary table doesn't make sense. All works fine when I use a global temporary table prefixed with ## as mentioned here:

https://microsoft.public.sqlserver.programming.narkive.com/eLv386EZ/bcp-queryout-cannot-be-from-a-temp-table#

Perhaps a warning could be added on the client side code, as the warning received from the SQL Server is not very explanatory...

TabLand avatar Jan 31 '24 12:01 TabLand