http://qs321.pair.com?node_id=509095


in reply to Datatypes. A Perl T-SQL comparison

This has nothing to do with perl, but the real reason why you get "incorrect syntax near cast" is that you need to use CAST in a select statement - just using CAST by itself makes no sense.

So something like

select CAST(@number_of_years AS INT)
would produce reasonable output.

Of course me I'd have declared @number_of_years as INT, and then used convert() or cast() in the assignments directly...

Michael