--- /dev/null
+package DBIx::Class::PK::Auto::MSSQL;\r
+\r
+use strict;\r
+use warnings;\r
+\r
+use base qw/DBIx::Class/;\r
+\r
+__PACKAGE__->load_components(qw/PK::Auto/);\r
+\r
+sub last_insert_id {\r
+ my( $id ) = $_[0]->storage->dbh->selectrow_array( 'SELECT @@IDENTITY' );\r
+ return $id;\r
+}\r
+\r
+1;\r
+\r
+=head1 NAME \r
+\r
+DBIx::Class::PK::Auto::MSSQL - Automatic Primary Key class for MSSQL\r
+\r
+=head1 SYNOPSIS\r
+\r
+=head1 DESCRIPTION\r
+\r
+This class implements autoincrements for MSSQL.\r
+\r
+=head1 AUTHORS\r
+\r
+Brian Cassidy <bricas@cpan.org>\r
+\r
+=head1 LICENSE\r
+\r
+You may distribute this code under the same terms as Perl itself.\r
+\r
+=cut
\ No newline at end of file
--- /dev/null
+use lib qw(lib t/lib);\r
+use DBICTest::Schema;\r
+\r
+use Test::More;\r
+\r
+my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER PASS/};\r
+\r
+#warn "$dsn $user $pass";\r
+\r
+plan skip_all, 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test'\r
+ unless ($dsn);\r
+\r
+plan tests => 1;\r
+\r
+DBICTest::Schema->compose_connection('MSSQLTest' => $dsn, $user, $pass);\r
+\r
+my $dbh = MSSQLTest::Artist->storage->dbh;\r
+\r
+$dbh->do("IF OBJECT_ID('artist', 'U') IS NOT NULL\r
+ DROP TABLE artist");\r
+\r
+$dbh->do("CREATE TABLE artist (artistid INT IDENTITY PRIMARY KEY, name VARCHAR(255));");\r
+\r
+MSSQLTest::Artist->load_components('PK::Auto::MSSQL');\r
+\r
+my $new = MSSQLTest::Artist->create({ name => 'foo' });\r
+\r
+ok($new->artistid, "Auto-PK worked");\r
+\r
+1;\r