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
 Development Tools
 Reporting Services Development
 Error converting from varchar to type int.

Author  Topic 

chriskhan2000
Aged Yak Warrior

544 Posts

Posted - 2004-12-15 : 10:30:29
When I try to pull up some data with I get this error:

Syntax error converting the varchar value 'Annie's Eatery Place' to a column of data type int.


Here's my query:

SELECT 0 AS ID, 'All' AS NAME
UNION
SELECT NAME, ID
FROM VENDOR
WHERE (TAX_ID IS NULL)
ORDER BY NAME

Can anyone help out? THanks in advance.

jhermiz

3564 Posts

Posted - 2004-12-15 : 12:19:14
Try flipping ID and Name ?

Can you show us DDL ?

Sample data ?

Your table structure?

What type is Annie's Eatery Place ?????


SELECT 0 AS ID, 'All' AS NAME
UNION
SELECT ID, NAME
FROM VENDOR
WHERE (TAX_ID IS NULL)
ORDER BY NAME

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-12-15 : 18:33:09
Yes, you'll need to flip ID and NAME:

SELECT 'All' AS NAME, 0 AS ID
UNION
SELECT NAME, ID
FROM VENDOR
WHERE (TAX_ID IS NULL)
ORDER BY NAME

The columns need to be in the same order.

Tara
Go to Top of Page

chriskhan2000
Aged Yak Warrior

544 Posts

Posted - 2004-12-16 : 11:01:27
Damn!!!!! You guys are good. That would've took me couple of days to figure out. Thanks again Jon and Tara.
Go to Top of Page
   

- Advertisement -