in reply to Win32::ODBC getting syntax error while executing sql

I don't know/can't remember much about SQL Server, but in $SqlStatement = <<ENDSQL;, perl treats ENDSQL as being double quoted, hence it will attempt to expand any variables it finds in the here document.

Since, from a perl POV, you reference a hash & number of arrays, I suspect this is generating an illegal SQL statement in $SqlStatement - try printing the variable.

If this _is_ the problem, it's easily cured by replacing $SqlStatement = <<ENDSQL; with $SqlStatement = <<'ENDSQL'; - note the single quotes.

HTH ,

A user level that continues to overstate my experience :-))