troubleshooting Question

SQL View - Convert varchar data type to int

Avatar of GStoner
GStoner asked on
Microsoft SQL Server 2005Microsoft Server Apps
5 Comments1 Solution800 ViewsLast Modified:
I'm trying to create a View in SQL 2000 that basically duplicates an existing table, but I need to change one of the field datatypes, so that I can use the View as a data source in a Crystal Report.  The field that I need to change from the existing table:
Name: CONTEXT
Data Type: varchar
Size: 255

There is a separat table/field that hold equivalent  data, but of a different type, that I'm trying to link it to in Crystal:
Name: CUSTOMERGROUPID
Data Type: int
Size: 4


I've tried using CONVERT, but I just can't seem to get the syntax right and it keeps giving errors.

Here's the View without doing any conversion:
SELECT     CONTEXT, SELECTEDVALUE
FROM         dbo.TBDHVALUES

I've tried several variations, such as the following, with no luck:
SELECT     CONVERT(int(4), CONTEXT)) as CUSTOMERGROUPID, SELECTEDVALUE
FROM         dbo.TBDHVALUES

What am I doing wroing?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros