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
 General SQL Server Forums
 New to SQL Server Programming
 Conversion failed when converting the varchar valu

Author  Topic 

ausla
Starting Member

7 Posts

Posted - 2012-07-16 : 01:10:57
hi all,
When i tried to execute this command i am getting this message.
Can anybody help me please.

My code is
SELECT Name = preferred_name + ' ' + surname, stud_code FROM tass.dbo.student WHERE year_grp='" + _StudentYear + "' and cmpy_code ='01' and dol is NULL ORDER BY surname

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-07-16 : 04:05:18
It's failing to convert a value. Probably you have a numeric column somewhere - _StudentYear maybe

SELECT Name = preferred_name + ' ' + surname, stud_code FROM tass.dbo.student WHERE year_grp='" + convert(varchar(20),_StudentYear) + "' and cmpy_code ='01' and dol is NULL ORDER BY surname

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -