Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing to local temp tables #178

Open
TabLand opened this issue Jan 31, 2024 · 1 comment
Open

Writing to local temp tables #178

TabLand opened this issue Jan 31, 2024 · 1 comment

Comments

@TabLand
Copy link

TabLand commented Jan 31, 2024

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...

@riziles
Copy link

riziles commented Jul 18, 2024

Suggested PR?

if (table_name[0] == "#") and ((table_name[1] != "#"):
  raise Exception("BCP cannot write to local temp tables")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants