Vous êtes ici :
Une petite procédure bien utile glanée sur le net : identifier le numéro de version interne d’un fichier .mdf
Pour la liste des versions, reportez-vous à cet article : http://blog.datafly.pro/post/Retrouvez-la-version-d-origine
Transact-SQL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
/*------------------------------------------------------------------- [SCRIPT] spDBVersion [DESCRIPTION] Obtenir le numéro de version interne d'un fichier .mdf [AUTHOR] msdn forum - jswansonpeopletrak [DATEMAJ] 20200221 -- For executing, you should authorize OLE Automation procedures -- EXEC sp_configure 'show advanced options', 1 -- RECONFIGURE -- GO -- EXEC sp_configure 'Ole Automation Procedures', 1 -- RECONFIGURE -------------------------------------------------------------------*/ CREATE /*ALTER*/ PROCEDURE spDBVersion ( @FilePath nvarchar(500) --Your filepath here EG 'C:\SQLData\somedatabase.mdf' ) AS DECLARE @HR int, @objStream int, @strErrorMessage Varchar(1000), @Source nvarchar(255), @Desc nvarchar(255), @offset bigint, @binary1 binary, @binary2 binary SET NOCOUNT ON SELECT @strErrorMessage='Creating ADO stream object' EXEC @HR = sp_OACreate 'ADODB.Stream' , @objStream OUT IF @HR <> 0 GOTO CLEANUP SELECT @strErrorMessage='Opening ADO stream' EXEC @HR = sp_OAMethod @objStream, 'Open' IF @HR <> 0 GOTO CLEANUP SELECT @strErrorMessage='Declaring ADO stream type binary' EXEC @HR = sp_OASetProperty @objStream, 'Type', 1 IF @HR <> 0 GOTO CLEANUP SELECT @strErrorMessage='Opening File into ADO stream' EXEC @HR = sp_OAMethod @objStream, 'LoadFromFile', NULL , @FilePath IF @HR <> 0 GOTO CLEANUP SELECT @offset = 73828 --9 * 8192 + 96 + 4 SELECT @strErrorMessage='Setting offset to read file' EXEC @HR = sp_OASetProperty @objStream, 'Position', @offset IF @HR <> 0 GOTO CLEANUP SELECT @strErrorMessage = 'Reading Version number from mdf' EXEC @HR = sp_OAMethod @objstream, 'Read', @binary1 OUT , 1 IF @HR <> 0 GOTO CLEANUP SELECT @strErrorMessage = 'Reading Version number from mdf' EXEC @HR = sp_OAMethod @objstream, 'Read', @binary2 OUT , 1 IF @HR <> 0 GOTO CLEANUP SELECT @binary1 + 256 * @binary2 AS DatabaseVersion END_ROUTINE: RETURN CLEANUP: BEGIN EXEC sp_OAGetErrorInfo @objStream, @Source OUT, @Desc OUT; SELECT ErrorInSP='spADOStreamData', HR = convert(varbinary(4),@HR), Source=@Source, Description=@Desc, Process=@strErrorMessage GOTO END_ROUTINE END GO |
Table of Contents