You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following fails at runtime with System.Data.SqlClient.SqlException: 'Invalid column name 'code'.'
altertable Users add column code int default 0;
update Users set code = id +1000;
This is a consistent behaviour with SSMS. This is solved using by separating the statement with GO. I do recall your explanation on how GO is used to virtually separate scripts so they are run individually. There is however no such equivalent statement. The current workaround is having the statements in different files.
Is it possible to have a statement that is equivalent to GO? Also, I'm not really sure if it is possible but if such codes can give an error at compile time, it will be very helpful since it will help with the statement that if it compiles, it works :)
The text was updated successfully, but these errors were encountered:
Tricky part here will be figuring out the rules T-SQL uses. Maybe it's as simple as that all queries in a single batch are run assuming the model that existed at the start of the batch (not updated in response to DDL statements run within the batch). But I feel like I've seen situations where that wasn't the case -- could be wrong. Needs experimentation.
The following fails at runtime with
System.Data.SqlClient.SqlException: 'Invalid column name 'code'.'
This is a consistent behaviour with SSMS. This is solved using by separating the statement with
GO
. I do recall your explanation on how GO is used to virtually separate scripts so they are run individually. There is however no such equivalent statement. The current workaround is having the statements in different files.Is it possible to have a statement that is equivalent to GO? Also, I'm not really sure if it is possible but if such codes can give an error at compile time, it will be very helpful since it will help with the statement that if it compiles, it works :)
The text was updated successfully, but these errors were encountered: