Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Strange result

Author  Topic 

psfaro
Starting Member

49 Posts

Posted - 2010-06-18 : 20:37:37
Hi

In SQL2008 Development

table "Mytable" column1 varchar(2) column2 varchar(10)

Query 1

select * from mytable where column2=1

//Returns error because column2 is Varchar not numeric

Query 2

select * from mytable where column1='14' and column2=1

//Returns all rows with column1=14 and column2=1

How is possible? column2 is varchar and the query is made with numeric

Regards
pedro faro

hambergler
Starting Member

9 Posts

Posted - 2010-06-18 : 22:55:49
This is for SQL Server 2005. The 2008 forums are here:

http://www.sqlteam.com/forums/default.asp?CAT_ID=9

Q1 - Also, I think you'll need quotes for your column2='1' argument.

Q2 - Again, try quotes.
Go to Top of Page

psfaro
Starting Member

49 Posts

Posted - 2010-06-19 : 20:13:47
Hi

I think the situation is the same in SQL2005

I know that i have to put the quotas.

Simply , i don´t understand why q1 gives error and q2 not.

Regards

Pedro
Go to Top of Page
   

- Advertisement -