try:
convert(smalldatetime,substring('20040910',1,4)+'-'+substring('20040910',5,2)+'-'+substring('20040910',7,2))
convert(smalldatetime,substring('20040910',1,4)+'-'+substring('20040910',5,2)+'-'+substring('20040910',7,2))
select convert (smalldatetime ,convert(char(4),'20040729')+'-'
+substring('20040729',5,2)+'-'
+substring('20040729',7,2))
set @str=20040910
select cast(@str as smalldatetime)