0
#!/usr/bin/perl

      use DBI;
      use Data::Dumper;
      use strict;


       my $DSN = q/dbi:ODBC:SQLSERVER/;
       my $uid = q/username/;
       my $pwd = q/password/;

       my $first_param=723454;
       my $current_date="2012-10-25 00:30:21";
       my $after_2min="2012-10-25 05:47:41";


       my $dbh = DBI->connect($DSN,$uid,$pwd) or die "Coudn't Connect SQL"; 

       my $sql2 = "insert reverise_call_main_menu call_number,call_originate_time,call_inbetween_time,call_after_2min_time) values(?,?,?,?)";
       my $sth2 = $dbh->prepare($sql2);
       $sth2->execute($first_param,$current_date,'null',$after_2min);

       $sth2->finish;
       $dbh->disconnect;

每当我执行程序时,都会出现以下错误:

输出:-

DBD::ODBC::st 执行失败:[unixODBC][FreeTDS][SQL Server]从字符串转换日期时间时转换失败。(SQL-22007)

4

1 回答 1

0

该错误消息表明 SQL Server 不喜欢您的日期时间字符串的格式。您可能希望使用DateTime::Format::DBI来帮助获得正确的格式。

于 2013-06-04T19:22:28.410 回答