Ask Question. Asked 9 years, 4 months ago. Active 5 years, 7 months ago. Viewed k times. IsNullOrEmpty myValue. Community Bot 1 1 1 silver badge. Snake Eyes Snake Eyes Add a comment. Active Oldest Votes. Massimiliano Peluso Massimiliano Peluso I like this idea, but would love to test the io performance against other methods.
The problem was OR. So I changed to AND. Sign up or log in Sign up using Google. Also, the distinct is unnecessary in your select statement. The group by already does this for you. Your hyphen in your ELSE statement isn't accepted in the column which is being defined under the datetime data type. You could either:. It helps you replace NULL values for other values. How are we doing? Please help us improve Stack Overflow.
Take our short survey. 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 8 years, 5 months ago. Active 5 months ago. Viewed k times. And if possible create another column and add the 30 days. What's wrong with the output you're getting now? Msg , Level 16, State 3, Line 1 The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
IsNull might help. Anax 8, 5 5 gold badges 30 30 silver badges 66 66 bronze badges. Adriano Carneiro Code Trawler Code Trawler 2 2 silver badges 7 7 bronze badges. Zach Johnson Zach Johnson 5 5 silver badges 12 12 bronze badges. When you say " Mansoor 12 12 bronze badges. Milan Milan 2, 1 1 gold badge 31 31 silver badges 43 43 bronze badges. Romain Durand Romain Durand 1 1 gold badge 5 5 silver badges 20 20 bronze badges.
Select Coalesce NullIf listing. OfferText, '' , NullIf company. Muhammad Sharjeel Ahsan Muhammad Sharjeel Ahsan 3 3 gold badges 13 13 silver badges 26 26 bronze badges. OfferText is null. However, the 2nd NULLIF call here serves no purpose, as if that value an empty string you're just going to coalesce back to an empty string anyway.
OfferText, '' , company. Here's a solution, but I don't know if it's the best Select Coalesce Case When Len listing. OfferText, 'company. Bo Persson Anoop Verma Anoop Verma 1, 14 14 silver badges 19 19 bronze badges. Rndm 6, 7 7 gold badges 36 36 silver badges 58 58 bronze badges. Code Crawler Code Crawler 43 5 5 bronze badges. This would be the first port of call but if you are doing things like concatenating from multiple columns in a table for example, then this would exclude the row rather than just display a blank for that column — Coops.
Paul Roub Hicham Hicham 31 1 1 bronze badge. Vedran Vedran 9, 4 4 gold badges 45 45 silver badges 57 57 bronze badges. This caters for spaces as well. ChrisM 6 6 silver badges 16 16 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.
0コメント