Using Perl I am parsing an fixed width file and fetching few fields that are being pushed to SQL DB later.
my $Date = 20170121; # Parsed from file my $file = Testfilename; # Parsed from file
Iam then making a connection to the DB and then the below lines of code follows
my $sql = "INSERT INTO TableName(Date,FileName) VALUES($Date,$file)"; my $stmt = $settle_dbh->prepare($sql); $stmt->execute();
Getting an error stating
DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver]Inval +id precision value (SQL-HY104)
Hence I tried to check what's passing in the $sql, the single quotes seem to be missing. Which I feel might be the issue.
print $sql; INSERT INTO TableName(Date,FileName) VALUES(20170121,Testfilename)
Can you please help me on how to get this resolved, may be in two ways which I could think of
1. Convert the date in Perl to format 2017-01-21 00:00:00.000
2. Passing the values in single quotes to SQL DB
In reply to Error passing string date from Perl to MSSQL by JobyJ
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |