ycherkes / OrcaSql

A C# parser for MDF files. Allows you to read tables, metadata and indexes from MDF files without it being attached to a running SQL Server instance.
http://improve.dk/archive/2011/05/03/introducing-orcamdf.aspx
GNU General Public License v3.0
17 stars 7 forks source link

Unable to select top 1000 rows #2

Closed CharlesOkwuagwu closed 2 years ago

CharlesOkwuagwu commented 2 years ago

Unable to select top 1000 rows


   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.BitConverter.ToInt16(Byte[] value, Int32 startIndex)
   at OrcaSql.Core.Engine.Pages.RecordPage.parseSlotArray() in C:\Projects\OrcaSql\src\OrcaSql.Core\Engine\Pages\RecordPage.cs:line 21
   at OrcaSql.Core.Engine.Pages.RecordPage..ctor(Byte[] bytes, Database database) in C:\Projects\OrcaSql\src\OrcaSql.Core\Engine\Pages\RecordPage.cs:line 13
   at OrcaSql.Core.Engine.Pages.TextMixPage..ctor(Byte[] bytes, Database database) in C:\Projects\OrcaSql\src\OrcaSql.Core\Engine\Pages\TextMixPage.cs:line 12
   at OrcaSql.Core.Engine.Database.GetTextMixPage(PagePointer loc) in C:\Projects\OrcaSql\src\OrcaSql.Core\Engine\Database.cs:line 189
   at OrcaSql.Core.Engine.Records.VariableLengthDataProxies.BlobInlineRootProxy.GetBytes() in C:\Projects\OrcaSql\src\OrcaSql.Core\Engine\Records\VariableLengthDataProxies\BlobInlineRootProxy.cs:line 45
   at OrcaSql.Core.Engine.Records.Parsers.PrimaryRecordEntityParser.<GetEntities>d__5.MoveNext() in C:\Projects\OrcaSql\src\OrcaSql.Core\Engine\Records\Parsers\PrimaryRecordEntityParser.cs:line 73
   at OrcaSql.Core.Engine.DataScanner.<ScanLinkedDataPages>d__5.MoveNext() in C:\Projects\OrcaSql\src\OrcaSql.Core\Engine\DataScanner.cs:line 62
   at OrcaSql.Core.Engine.DataScanner.<ScanPartition>d__7.MoveNext() in C:\Projects\OrcaSql\src\OrcaSql.Core\Engine\DataScanner.cs:line 143
   at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
   at System.Linq.Enumerable.<CastIterator>d__97`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at OrcaSql.Core.MetaData.BaseTableData.get_SysObjValues() in C:\Projects\OrcaSql\src\OrcaSql.Core\MetaData\BaseTableData.cs:line 39
   at OrcaSql.Core.MetaData.DMVs.SqlModule.<>c__DisplayClass31_0.<GetDmvData>b__1(sysschobj o) in C:\Projects\OrcaSql\src\OrcaSql.Core\MetaData\DMVs\SqlModule.cs:line 53
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at OrcaSql.Core.MetaData.DMVs.SqlModule.GetDmvData(Database db) in C:\Projects\OrcaSql\src\OrcaSql.Core\MetaData\DMVs\SqlModule.cs:line 51
   at OrcaSql.Core.MetaData.DmvGenerator.get_SqlModules() in C:\Projects\OrcaSql\src\OrcaSql.Core\MetaData\DmvGenerator.cs:line 44
   at OrcaSql.Core.MetaData.DMVs.SysDefaultConstraint.GetDmvData(Database db) in C:\Projects\OrcaSql\src\OrcaSql.Core\MetaData\DMVs\SysDefaultConstraint.cs:line 132
   at OrcaSql.Core.MetaData.DmvGenerator.get_SysDefaultConstraints() in C:\Projects\OrcaSql\src\OrcaSql.Core\MetaData\DmvGenerator.cs:line 38
   at OrcaSql.Core.Engine.DataScanner.<ScanPartition>d__7.MoveNext() in C:\Projects\OrcaSql\src\OrcaSql.Core\Engine\DataScanner.cs:line 118
   at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
   at System.Linq.Enumerable.<TakeIterator>d__25`1.MoveNext()
   at OrcaSql.OSMS.Main.ShowRows(IEnumerable`1 rows, Row schemaRow, String tableName, Int64 rowCount) in C:\Projects\OrcaSql\src\OrcaSql.OSMS\Main.cs:line 514
   at OrcaSql.OSMS.Main.LoadTable(String table, Nullable`1 schemaId, Int64 rowCount) in C:\Projects\OrcaSql\src\OrcaSql.OSMS\Main.cs:line 450
ycherkes commented 2 years ago

That's interesting. What version of SQL Server do you use?

CharlesOkwuagwu commented 2 years ago

2017 sir

CharlesOkwuagwu commented 2 years ago

That's interesting. What version of SQL Server do you use?

Also unable to export stored procedures, error at exactly the same palce

ycherkes commented 2 years ago

Could you send me some example.mdf with no significant data where this bug is reproducible?

CharlesOkwuagwu commented 2 years ago

Could you send me some example.mdf with no significant data where this bug is reproducible?

the MDF is corrupt, I'm trying to recover it as much as possible

ycherkes commented 2 years ago

Looks like the sys.sysobjvalues table is broken.

CharlesOkwuagwu commented 2 years ago

Looks like the sys.sysobjvalues table is broken.

No idea... what can we do?

I Was able to read the .mdf file with a 3rd-party product and do a full extraction... from the broken .mdf file

but really wanted to use your code to do this, what can we do?

CharlesOkwuagwu commented 2 years ago

can i share the broken MDF privately over 1GB zipped

ycherkes commented 2 years ago

Yes, you can share it via Google Drive - my Gmail account is smurtdev[at]gmail.com. But I can spend some time just this weekend. Is your database attached to an SQL Server? I mean can you run DBCC checkdb command against it?

CharlesOkwuagwu commented 2 years ago

Yes, you can share it via Google Drive - my Gmail account is smurtdev[at]gmail.com. But I can spend some time just this weekend. Is your database attached to an SQL Server? I mean can you run DBCC checkdb command against it?

not able to attach, it fails, hence the need to extract data directly from the .mdf file

ycherkes commented 2 years ago

Have you tried to attach this Db as described here: I would recommend doing it in a test environment. https://stackoverflow.com/questions/38995380/sql-server-how-to-attach-repair-a-detached-damaged-database http://www.sqlskills.com/blogs/paul/disaster-recovery-101-hack-attach-a-damaged-database/

CharlesOkwuagwu commented 2 years ago

Have you tried to attach this Db as described here: I would recommend doing it in a test environment. https://stackoverflow.com/questions/38995380/sql-server-how-to-attach-repair-a-detached-damaged-database http://www.sqlskills.com/blogs/paul/disaster-recovery-101-hack-attach-a-damaged-database/

I did not know of this, I will try it now

ycherkes commented 2 years ago

@CharlesOkwuagwu Any news?

CharlesOkwuagwu commented 2 years ago

sorry, will send now .... via WeTransfer, upload might take a few minutes

ycherkes commented 2 years ago

Not an issue - the database was broken.