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 2000 Forums
 Transact-SQL (2000)
 convertion

Author  Topic 

kemi2299
Starting Member

41 Posts

Posted - 2008-04-04 : 09:27:30
could you pls check this query, i need to convert the varchar to int but i am getting error
Conversion failed when converting the varchar value '*' to data type int. what is missing?

SELECT count(Mrn) as counter, month_Att,Attendance_Cat_Cd
into #lcdq16b from #lcae
where convert(varchar,Attendance_Cat_Cd )= 1
group by month_Att,Attendance_Cat_Cd ;

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-04-04 : 09:33:26
quote:
Originally posted by kemi2299

could you pls check this query, i need to convert the varchar to int but i am getting error
Conversion failed when converting the varchar value '*' to data type int. what is missing?

SELECT count(Mrn) as counter, month_Att,Attendance_Cat_Cd
into #lcdq16b from #lcae
where convert(varchar,Attendance_Cat_Cd )= 1
group by month_Att,Attendance_Cat_Cd ;





the problem is this bit in red

could you not just say where attendance_cat_cd = 1? the conversion to varchar seems pointless as it is?
what datatype is it to start with?


Em
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-04 : 09:57:59
1 Always specify column length during convertion
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/12/04/column-length-and-data-length.aspx

2 Are you sure Attendance_Cat_Cd has only numbers?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -