my $server_name = 'production\reporting'; my $database_name = 'test'; my $DSN = "driver={SQL Server};server=$server_name;database=$database_name;"; my $dbh = DBI->connect("dbi:ODBC:$DSN", {PrintError =>0, RaiseError =>1}); eval { if (!$dbh) { print "Could not connect to database: $DBI::errstr"; } if($dbh) { print "Connected to DB!!"; } my $sql = "INSERT INTO Count VALUES ()"; my $sth = $dbh->prepare($sql); $sth->execute(); }; if($@) { $dbh->disconnect(); QuitProgram("DB Failure: $@"); }