ExecuteWithResultsAndMessage2 SQL-DMO And Perl

Jul 23, 2005

Hello to all:

I want to get the output from xp_msver through
ExecuteWithResultsAndMessage2 SQL-DMO and perl. This is the script
I've got so far. Can anyone give me a few more pointers?

use strict;
use Win32::OLE 'in';
use Win32::OLE::Const 'Microsoft SQLDMO Object Library';

my ($server, $obj, $job, $jobs, $pathname, $c, $qr, $m );
my $srv;
my @servers = qw( KORTRIGHT );

$server = Win32::OLE->new('SQLDMO.SQLServer2')
or die "Could not create SQLDMO object.";

$server->{LoginSecure} = 1;

foreach $srv (@servers) {

$server->connect($srv, '', '');
if (Win32::OLE->LastError()) {
die "***Err: Could not connect to $srv.";
}

printf qq[
%10.10s %-50.50s %10.10s %s
], "Hostname:",
$server->HostName, "Server:", $srv;

my $dbs = $server->Databases();
if (Win32::OLE->LastError()) {
die "**Err: Could not get the alerts collection in $srv.";
}

foreach $obj (in($dbs)) {
printf qq[%10.10s %-50.50s %10.10s %s
], "Database:",
$obj->Name, "Size:", $obj->Size." Mb";
}

$jobs = $server->Jobserver;

foreach $obj (in($jobs->Jobs() ) ) {
if( $obj->Name =~ /'(.*)'/ ) {
$job = $1;
}
foreach my $step ( in($obj->Jobsteps()) ) {
if( $step->command =~ /-BkUpDB "(S+)"/ ) {
$pathname = $1;
printf qq[%10.10s %s
], "Job:", $job;
printf qq[%10.10s %s
], "pathname:", $pathname;
#print $step->command.qq[
];
}
}
}

$c = "xp_msver";
$qr = $server->ExecuteWithResultsAndMessages2( $c, $m );
$server->DisConnect;
}

View 1 Replies


ADVERTISEMENT

Perl DBD/DBI For SQL Server

Jul 20, 2005

we have ODBC drivers to connect to SQL Server from a unix box.I looked at cspan.org for Perl DBD/DBI with sql server and Idon't see one. Is there a place from where I can downloadperl DBD/DBI for SQLServer.Thanks.

View 3 Replies View Related

Perl Script Question

Apr 19, 2004

I have a question regarding a SQL statement that I have in my perl program.

I am using the following code:
# SQL scalar
my ($SQL);

# Scalars for database columns
my ($userid, $username, $useremail, $userpwd, $useroffice);

# Initialise the values for an example request
$userid = "5";
$username = "alice";
$useremail = "alice@yahoo.com";
$userpwd = "blah2000";
$useroffice = "san antonio";


$SQL = "INSERT INTO users (userid, username, useremail, userpwd, useroffice) VALUES ('$userid', '$username', '$useremail', '$userpwd', '$useroffice')";

# Run the SQL query
if ($db->Sql($SQL))
{
print "Error on SQL INSERT";
Win32::ODBC::DumpError();

} # End if

print "<p>Running: $SQL<br>";
print "Note: $username has been created";


if you notice the useremail section includes a '@' character. This is not going to display the result that I want. How do I get perl to print the full email address correctly.

Right now, the result looks like this:

5 alice alice.com blah2000 san antonio

but I want it to display alice@yahoo.com

Any suggestions?
Thank You.
-Laura

View 3 Replies View Related

Parsinf Data From Perl To Ms Sql Server

Nov 21, 2006

Hello

I have a desktop in which i have installed perl. I have another machine with OS as windows server 2003 and install ms sql server 2005. My problem is that i want to send data from my desktop to the window server how do i do that.
And help please.

View 3 Replies View Related

Perl Connection String For SQLexpress

Apr 29, 2008

#!perl

I am having difficulty converting my CGI(perl module) connection from mySQL to SQLexpress. Does anyone know what the connection string should look like?
Listed here is my current connection string. I'm trying to get this done this week. Please email me if you have an answer in addition to posting.

$dbh = DBI->connect("DBI:mysql:database=$var{database};host=$var{server}","$var{root_username}", "$var{root_password}",{'RaiseError' => 0, 'PrintError' => 0});

Much appreciated,

JOhn

View 2 Replies View Related

Problems Connecting To SQL Server DB Using Perl CGI

Jul 15, 2004

Please help. I am at my wits end.

I have SQL Server 2000 on a Windows 2003 server. I have my database on a Nmade Instance . Named Pipes is disabled and only TCP/IP is enabled. Authentication is set to Windows only. The server is in Active Directory.

My web site is on a Windows 2000 server with IIS 5. I have installed the Client Network Utilities and set the alias to TCP/IP also. I can connect to the SQL server using the Query Analyzer.

I have downloaded and installed ActiveState's ActivePerl 5.6.1.638-MSWin32-x86.msi on both machines. I have also installed DBI and DBD::ODBC on both machine. Both machine have MDAC 2.8 installed.

The code I am using to connect is as follows:
my $user = 'user';
my $pass = 'password';
my $db = "database";
my $server = "servername\instancename";
my $ipadd = "xxx.xx.xx.xxx,xxxx";
my $driver = '{SQL Server}';

Option #1
$DSN = 'driver=$driver;Server=$server;uid=$user;pwd=$pass;database=$db;network=DBMSSOCN;address=$ipadd;';
$dbh = DBI->connect("dbi:ODBC:$DSN") or die 'Cannot Open SQL Server Database $DBI::errstr';

Option #2
$DSN = 'driver=$driver;Server=$server;uid=$user;pwd=$pass;database=$db';
$dbh = DBI->connect("dbi:ODBC:$DSN") or die 'Cannot Open SQL Server Database $DBI::errstr';

Option #3
$dbh = DBI->connect('dbi:ODBC:driver=$driver:dsn',$user,$pass) or die 'Cannot Open SQL Server Database $DBI::errstr';

Option #4
$dbh = DBI->connect("dbi:ODBC:database=$db;server=$server",$user,$pass) or die '$DBI::errstr';

From all that I have read and from previous scripts I have written, any of these should work, but I am getting the following error.

DBI connect('driver=$driver:dsn','user',...) failed: at C:cgi-binCGI.pl line xxx Cannot Open SQL Server Database $DBI::errstr at C:cgi-binCGI.pl line xxx.
Where xxx = the line number of the connection call.

All of my previous scripts have been written for forms where the web server(Apache), database(MySQL), and script(Perl CGI) are all on the same machine. I am not at all familiar with SQL Server, and am struggling to learn quickly. PLease any ideas would be greatly appreciated.
Thank you

LANAC

View 1 Replies View Related

Problems Connecting To SQL Server DB Using Perl CGI

Jul 15, 2004

Please help. I am at my wits end. :confused:

I have SQL Server 2000 on a Windows 2003 server. I have my database on a Nmade Instance . Named Pipes is disabled and only TCP/IP is enabled. Authentication is set to Windows only. The server is in Active Directory.

My web site is on a Windows 2000 server with IIS 5. I have installed the Client Network Utilities and set the alias to TCP/IP also. I can connect to the SQL server using the Query Analyzer.

I have downloaded and installed ActiveState's ActivePerl 5.6.1.638-MSWin32-x86.msi on both machines. I have also installed DBI and DBD::ODBC on both machine. Both machine have MDAC 2.8 installed.

The code I am using to connect is as follows:
my $user = 'user';
my $pass = 'password';
my $db = "database";
my $server = "servername\instancename";
my $ipadd = "xxx.xx.xx.xxx,xxxx";
my $driver = '{SQL Server}';
Option #1
$DSN = 'driver=$driver;Server=$server;uid=$user;pwd=$pass ;database=$db;network=DBMSSOCN;address=$ipadd;';
$dbh = DBI->connect("dbi:ODBC:$DSN") or die 'Cannot Open SQL Server Database $DBI::errstr';

Option #2
$DSN = 'driver=$driver;Server=$server;uid=$user;pwd=$pass ;database=$db';
$dbh = DBI->connect("dbi:ODBC:$DSN") or die 'Cannot Open SQL Server Database $DBI::errstr';

Option #3
$dbh = DBI->connect('dbi:ODBC:driver=$driver:dsn',$user,$pass) or die 'Cannot Open SQL Server Database $DBI::errstr';

Option #4
$dbh = DBI->connect("dbi:ODBC:database=$db;server=$server",$user,$pass) or die '$DBI::errstr';

From all that I have read and from previous scripts I have written, any of these should work, but I am getting the following error.

DBI connect('driver=$driver:dsn','user',...) failed: at C:cgi-binCGI.pl line xxx Cannot Open SQL Server Database $DBI::errstr at C:cgi-binCGI.pl line xxx.
Where xxx = the line number of the connection call.

All of my previous scripts have been written for forms where the web server(Apache), database(MySQL), and script(Perl CGI) are all on the same machine. I am not at all familiar with SQL Server, and am struggling to learn quickly. PLease and ideas would be greatly appreciated.
Thank you
LANAC

View 2 Replies View Related

IF EXISTS Statement In My Perl Program

Aug 23, 2004

I am having trouble finishing my query.

This is what I have:

IF EXISTS(Select ApplicationID from Application Where Application = '&_')
Insert Into PCApp(ApplicationID, SystemNetName)
Values( , $HoH->{Host}{SystemNetName})

I am not sure what to put in the blank within the Values parenthesis. I need to obtain the ApplicationID that is checked in the IF EXISTS section. But I cannot put a select statement into the Values() section.

Any suggestions would be appreciated.

Thanks,
Laura

View 13 Replies View Related

Returning Values From SP To Perl Script.

Apr 2, 2008

I am just starting to learn about stored procs and how great they can make my world. I have been able to create a pro that does some data checking and inserts based on the results but what I have not been able to figure out is how would I pass a message from the proc to my Perl script that calls it? If anyone could point me in the right direction on what commands I should be looking into I would appreciate it.

--
If I get used to envying others...
Those things about my self I pride will slowly fade away.
-Stellvia

View 1 Replies View Related

Connect Using Perl (solaris Platform)

Apr 23, 2007



I need to connect to Express edition of sql server installed on my machine, from perl (solaris platform). How should the connection string containing server, port, database etc look like ??

View 5 Replies View Related

Parse Text File (csv, Fix Width), Perl Or Something Newer?

May 26, 2007

I need to parse some text files and load them to database - these files are mostly CSV files or fix width columns format and the column names (first line) may vary in text (e.g. different abbreviation), order and extra columns, etc.

Is it a good idea have this done using script task of SSIS? How it compare to Perl on performance? Or any other tools good for this?

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved