March 31, 2015 at 3:40 am
select weekday from Petrol_Costs_Table where Weekday ='thursday';
i am getting an error as follows:-
The data types text and varchar are incompatible in the equal to operator.
the column weekday is type text
can anybody help here.... 🙂
March 31, 2015 at 3:44 am
Why is a column which contains the days of the week a text column which allow for up to 2 billion characters?
Alter the table and set the column to a more sensible data type.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
March 31, 2015 at 3:50 am
GilaMonster (3/31/2015)
Why is a column which contains the days of the week a text column which allow for up to 2 billion characters?Alter the table and set the column to a more sensible data type.
WHY !!
March 31, 2015 at 4:00 am
Excuse me??? I don't appreciate being shouted at.
I suggest changing the table definition because you're using a completely inappropriate data type for the column. The text data type is for really, really, really large strings, over 8000 characters and because it's designed for data of that size it can't be used in equality comparisons. So fix the cause of the problem, which is the really poor choice of data type, use a data type that's appropriate for 10-character long strings and you'll be able to do equality comparisons on it.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
March 31, 2015 at 4:22 am
GilaMonster (3/31/2015)
Excuse me??? I don't appreciate being shouted at.I suggest changing the table definition because you're using a completely inappropriate data type for the column. The text data type is for really, really, really large strings, over 8000 characters and because it's designed for data of that size it can't be used in equality comparisons. So fix the cause of the problem, which is the really poor choice of data type, use a data type that's appropriate for 10-character long strings and you'll be able to do equality comparisons on it.
This is the type of answer i was hoping to get. 🙂
if you had type this in the first place, then i would not have shouted... hehe
Thank you for your First informative reply.
March 31, 2015 at 4:33 am
sherm (3/31/2015)
This is the type of answer i was hoping to get. 🙂if you had type this in the first place, then i would not have shouted... hehe
I would have told you to cast to varchar for your rudeness, so you would fight with it forever.
Gail has been far more kind with you than you would deserve.
-- Gianluca Sartori
March 31, 2015 at 4:55 am
spaghettidba (3/31/2015)
sherm (3/31/2015)
This is the type of answer i was hoping to get. 🙂if you had type this in the first place, then i would not have shouted... hehe
I would have told you to cast to varchar for your rudeness, so you would fight with it forever.
Gail has been far more kind with you than you would deserve.
if you had said that, i would have totally ignored you, as i know that was not the correct type.
as i said if gail had finished off his sentence in his first post, then i would not have asked WHY!
the only rudeness on my part was making the "why" as big as i did.....
any way thanks to gail's second post. i have found the solution.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply