I have a simple request
CREATE TABLE #tempTable (id int) DROP TABLE #tempTable CREATE TABLE #tempTable (id int) DROP TABLE #tempTable
From my understanding, in the second part, it should create #tempTable .
But it shows the following error
Msg 2714, Level 16, State 1, Line 4
There is already an object in the database with the name "#tempTable".
I searched for the reason and found that it was because of the GO statement between the two parts of the request. Therefore, the correct request
CREATE TABLE #tempTable (id int) DROP TABLE #tempTable GO CREATE TABLE #tempTable (id int) DROP TABLE #tempTable
I also found that GO simply tells SSMS to send SQL statements between each GO in separate batches sequentially.
My question is: how are SQL statements executed? Is it running sequentially?
If it is executed sequentially, then why is my first request causing an error?
sql-server tsql ssms
Noor a shuvo
source share