Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 10 years, 8 months ago. Active 9 years, 8 months ago. Viewed k times. Is it possible to set NULL value for int column in update statement? How can I write the update statement in this case? Juan Mellado Maanu Maanu 4, 11 11 gold badges 52 52 silver badges 78 78 bronze badges.
Add a comment. I've always cast the remaining queries to the types of the first select. Never realized that it was picking types in a different way. Tom, you are right, columns 22 thru 26 are integers, I was so focused on the last ones that I didn't notice it. But, forgive me for my curiosity, this thread is becoming highly instructive to me, why the following queries runs fine, while mine does not? It is a good idea to always be explicit. If you're selecting a constant, use a CAST to specify the type you need this constant to be.
I don't know if the rules how compiler chooses the type of the constant are documented they should be , but I know, what if it sees a number without decimal that fits into integer range, it automatically assumes integer.
For every expert, there is an equal and opposite expert. I guess since they are literals, SQL looks at the whole query and since every thing is literal values inside that, it figures out which type to use and somehow decides to use varchar. I don't know why it works that way. It doesn't seem consistent to me, because you get results like. And I don't know of anyplace where the documentation states that NULL will be treated as an int if SQL is not given any other way to determine the datatype.
I just know it is. And I don't know why they chose int as opposed to something else. One recommendation I would have is anytime you have a literal in the definition of a view whether it is a NULL or an actual value , cast it to the type you want it to have. Then you don't have to worry about what SQL might assume the datatype of that literal is. So instead of. Sign in. United States English. You also have the option to opt-out of these cookies.
But opting out of some of these cookies may affect your browsing experience. Necessary Necessary. Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously. The cookie is used to store the user consent for the cookies in the category "Analytics". The cookies is used to store the user consent for the cookies in the category "Necessary".
The cookie is used to store the user consent for the cookies in the category "Other. The cookie is used to store the user consent for the cookies in the category "Performance".
It does not store any personal data. Functional Functional. Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features. Performance Performance. Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors. Analytics Analytics.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc. Advertisement Advertisement. Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others Others. Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
0コメント