Hi,
I have a problem on Windows running a perl script that (I think would) works on 'nix.
I've got some text files with the words COLLATE SQL_Latin1_General_... in them. The following script would remove it on nix.
On my Windows machine, it doesn't change the file but it does create the backup files.
Any help on this is much appreciated.
Iain
#!/usr/bin/perl
use warnings;
use strict;
$^I = "~";
while(<>)
{
if( /CP1_CI_AS/ ) {
s/COLLATE\s+?SQL_Latin1_General_CP1_CI_AS/ / ;
}
if ( /_CI_AS\s+?Latin1_General_CI_AS/ ) {
s/COLLATE\s+?Latin1_General_CI_AS/ /;
}
print;
}
the command i run through cygwin is:
./removeCollate.pl *.*
and here is an example of one of the data files
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Affiliates]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Affiliates](
[AffiliateID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
CONSTRAINT [PK_Affiliates] PRIMARY KEY CLUSTERED
(
[AffiliateID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
I have a problem on Windows running a perl script that (I think would) works on 'nix.
I've got some text files with the words COLLATE SQL_Latin1_General_... in them. The following script would remove it on nix.
On my Windows machine, it doesn't change the file but it does create the backup files.
Any help on this is much appreciated.
Iain
#!/usr/bin/perl
use warnings;
use strict;
$^I = "~";
while(<>)
{
if( /CP1_CI_AS/ ) {
s/COLLATE\s+?SQL_Latin1_General_CP1_CI_AS/ / ;
}
if ( /_CI_AS\s+?Latin1_General_CI_AS/ ) {
s/COLLATE\s+?Latin1_General_CI_AS/ /;
}
print;
}
the command i run through cygwin is:
./removeCollate.pl *.*
and here is an example of one of the data files
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Affiliates]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Affiliates](
[AffiliateID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
CONSTRAINT [PK_Affiliates] PRIMARY KEY CLUSTERED
(
[AffiliateID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END