my $sql = ' declare @id int exec GetTest ?, @id out select GotID = @id '; my $sth = $dbh->prepare($sql); if ( $sth->execute('foo') ) { while (my $hash = $sth->fetchrow_hashref ) { foreach my $key (keys %$hash) { print $key . " => " . $$hash{$key} . "\n" if $$hash{$key}; }; } }