I want help on Sql query
-
Hi Friends I have a problems I have a table Employee two fields Name, Age Name Datatype is varchar() Age Datatype is Int() the table look likes this Name.........Age Ram.............23 Steve............22 when i swap this two fields using this query"update Employee set Age = Ename,Ename=Age;' then the error occured error is "Syntax error converting the varchar value 'Ram' to a column of data type int." If i changed the datatype of Age is "Int" to "Varchar" then the query runs. My question is if i don't changed the datatype then how i swap the two fields Plz help me....
-
Hi Friends I have a problems I have a table Employee two fields Name, Age Name Datatype is varchar() Age Datatype is Int() the table look likes this Name.........Age Ram.............23 Steve............22 when i swap this two fields using this query"update Employee set Age = Ename,Ename=Age;' then the error occured error is "Syntax error converting the varchar value 'Ram' to a column of data type int." If i changed the datatype of Age is "Int" to "Varchar" then the query runs. My question is if i don't changed the datatype then how i swap the two fields Plz help me....
It seems to me you don't understand the difference between a varchar column versus an int column. A varchar column is used to store text while an int column is used to store numbers. You cannot do what you are trying do, becuase you cannot put Text into an Integer column, which is why you get the error message 'Syntax error converting the varchar value 'Ram' to a column of data type int'. Further, I don't see any reason why you would ever want to do this, as it just doesn't make any sense.
Mike Lasseter
-
It seems to me you don't understand the difference between a varchar column versus an int column. A varchar column is used to store text while an int column is used to store numbers. You cannot do what you are trying do, becuase you cannot put Text into an Integer column, which is why you get the error message 'Syntax error converting the varchar value 'Ram' to a column of data type int'. Further, I don't see any reason why you would ever want to do this, as it just doesn't make any sense.
Mike Lasseter
"cast age as varchar" convert data type for select caluse,dot know update
-
Hi Friends I have a problems I have a table Employee two fields Name, Age Name Datatype is varchar() Age Datatype is Int() the table look likes this Name.........Age Ram.............23 Steve............22 when i swap this two fields using this query"update Employee set Age = Ename,Ename=Age;' then the error occured error is "Syntax error converting the varchar value 'Ram' to a column of data type int." If i changed the datatype of Age is "Int" to "Varchar" then the query runs. My question is if i don't changed the datatype then how i swap the two fields Plz help me....
how about 'Cast age as varchar', not sure