package MytoMSSQL; ################################################## ######################## Routines to convert MySQL to MSSQL ################################################## sub convert { my $sql = $_[0]; #int(12) not null primary key auto_increment TO int IDENTITY(1,1) PRIMARY KEY CLUSTERED if ($sql =~ /int\(.*?\) not null primary key auto_increment/) { $sql =~ s/int\(.*?\) not null primary key auto_increment/int IDENTITY\(1,1\) PRIMARY KEY CLUSTERED/gis; } ## End if if ($sql =~ /not null primary key auto_increment/) { $sql =~ s/not null primary key auto_increment/IDENTITY\(1,1\) PRIMARY KEY CLUSTERED/gis; } ## End if #timestamp(8) TO timestamp if ($sql =~ /timestamp\(.*?\)/) { $sql =~ s/timestamp\(.*?\)/timestamp/gis; } ## End if #int(12) TO int AND bigint(20) TO bigint if ($sql =~ /int\(.*?\)/) { $sql =~ s/int\(.*?\)/int/gis; } ## End if return $sql; } ## End sub ################################################## ######################## Routines to prepare ################################################## sub prepare { my ($sql, $convert, $ddbh) = @_; if ($ddbh) { $dbh = $ddbh; } ## End if if ($convert) { $sql = &convert($sql); } ## End if return $dbh->prepare($sql); } ## End sub 1;