package SQL::Translator::Parser::DBI::SQLServer;
# -------------------------------------------------------------------
-# $Id: SQLServer.pm,v 1.1 2005-06-27 19:00:19 duality72 Exp $
-# -------------------------------------------------------------------
-# Copyright (C) 2002-4 SQLFairy Authors
+# Copyright (C) 2002-2009 SQLFairy Authors
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
use Data::Dumper;
use vars qw[ $DEBUG $VERSION @EXPORT_OK ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/;
+$VERSION = '1.60';
$DEBUG = 0 unless defined $DEBUG;
no strict 'refs';
FROM syscomments c
JOIN sysobjects o
ON c.id = o.id
- WHERE o.type ='P'
+ WHERE o.type in ('P', 'FN', 'TF', 'IF')
}
);
) || die $table->error;
$f->is_nullable($c->{NULLABLE} == 1);
$f->is_auto_increment($is_auto_increment);
- $c->{COLUMN_DEF} =~ s#\('?(.*?)'?\)#$1#;
- $f->default_value($c->{COLUMN_DEF}) if defined $c->{COLUMN_DEF};
+ if ( defined $c->{COLUMN_DEF}) {
+ $c->{COLUMN_DEF} =~ s#\('?(.*?)'?\)#$1#;
+ $f->default_value($c->{COLUMN_DEF});
+ }
}
# add in primary key
}
# add in foreign keys
- my $h = $dbh->selectall_hashref("sp_fkeys NULL,
+ $h = $dbh->selectall_hashref("sp_fkeys NULL,
\@fktable_name = '$table_info->{TABLE_NAME}'", 'FK_NAME');
foreach my $fk ( values %{$h} ) {
my $constraint = $table->add_constraint( name => $fk->{FK_NAME},
} elsif ($table_info->{TABLE_TYPE} eq 'VIEW') {
next if $table_info->{TABLE_NAME} eq 'sysconstraints'
|| $table_info->{TABLE_NAME} eq 'syssegments';
+ next if !$stuff->{view}->{$table_info->{TABLE_NAME}}->{text};
my $view = $schema->add_view(
name =>
$table_info->{TABLE_NAME},
}
foreach my $p (values %{$stuff->{procedures}}) {
+ next if !$p->{text};
my $proc = $schema->add_procedure(
name => $p->{name},
owner => $p->{PROCEDURE_OWNER},