SQL USE DatabaseName overwrites Data ?
AnsweredHi ,
I'm usually writing most queries in MSSMS since I find it a lot easier.
I've recently encountered an odd situation where data is being overwritten between databases if SQL query report is using the "USE" command, below is an example of my setup :
Production Env . example db name is : CompanyDb
Test Env (old dated replica of the CompanyDb) :TestCompanyDb
What Happen to me was I was creating a query on the CompanyDb ,
but when I started writing the query I used the "Use CompanyDb", and then I queried my data.
I proceeded to my test SBO company against TestCompanyDb and pasted the query .
What followed is that I started receiving "Database Structure Changed" messages from SBO .
and I could see that some of my data was overwritten (eg. UF , Menus etc etc.)
I'm trying to pay close attention ever since not to use USE command on SQL report UF , but this caused a lot of "damage" and I'm afraid that if my test Database was even older I wouldn't have been able to easliy fix this.
Any input from BOYUM regarding this / if you can confirm / replicate this scenario is much appreciated, perhaps it's a bug , or maybe I was doing something awfully wrong.
Thank you ,
Nadav.
-
Official comment
Hello Nadav,
We don't have a specific behaviour for the query report, it is like you're running the Query manager.
What I would suggest is to avoid the USE command and only use the SQL syntax Database.[dbo].Table I´ve worked with that before with good results.
Here is an example:

-
Hi Yaremi ,
I understand the workaround, but I'm bringing this up to prevent a lot of pain for other B1up users that has duplicate test env.
Unfortunately it's an easy mistake to make when coming from sql managment studio , and it reproduces if some one accidentally uses USE command on the TEST database .
E.g.
USE [prodDB]
Select top 10 t0.* from OITM
If I run this accidentally on the TestDB the entire B1up DB on the prodDB is overwritten with the data from the TestDB.
please try to see if this reproduces on your system. maybe it's only an issue with old versions of B1UP
I'm running 2019.04.01.0
Thank you !
-
Hello Nadav,
For further investigation in this case, please contact your local partner, they will follow up this case with us.
Thank you!
Please sign in to leave a comment.
Comments
3 comments