martes, 18 de octubre de 2011

Recover MSDB Database in suspect mode

If you don't have a msdb backup, follow these steps:

1.-Stop the SQL services
2.-Navigate to the directory ‘C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn’
3.-Start the SQL services with trace flag 3608 using following command : start sqlservr.exe -c -T3608 -s INSTANCENAME
4.-Detach the damaged msdb: sqlcmd -S INSTANCENAME -E -Q "EXEC sp_detach_db 'msdb','TRUE' "
5.-Move or rename the damaged msdb files (msdbdata.mdf and msdblog.ldf in the Data directory)
6.-Run the instmsdb.sql script in the ‘C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Install’ directory
sqlcmd -E -S INSTANCE -i instmsdb.sql
7.-Stop the SQL services
8.- Restart the SQL services without the 3608 trace flag
9.- Check your db isn't suspect
10.- Recreate all jobs/alerts/operators

(The 3608 Trace flag, prevents SQL Server from automatically starting and recovering any database except the master database.)

For activate remote connections to SQL Server check this link: http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277"

MSDB database is marked as suspect

1) I shut down the server, navigating to the directory 'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLBinn' and doing the following: start sqlservr.exe -c -T3608
2) renamed the damaged msdb files (msdbdata.mdf and msdblog.ldf in the 'd:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLData' directory)
3) Run the instmsdb.sql script in the 'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLInstall' directory

miércoles, 5 de octubre de 2011

XBRL (extensible Business Reporting Language)

Conocido por su acrónimo XBRL, este estándar nace de la propuesta lanzada en 1998 por Charles Hoffman, un experto contable y auditor, para simplificar la automatización del intercambio de información financiera.
XBRL es un paso adelante necesario hacia la estandarización de los procesos de transmisión y recepción de la información financiera y de negocio que demanda la situación de la comunicación de la información financiera actual según la problemática descrita.

jueves, 8 de septiembre de 2011

VBScript for compact Access Database

This script compact an Access Database, without the needed of having an Access installation on your Operating System.

Only replace FULLPATHFILENAME and FULLPATHFILENAME2 for original database and temporal database for compacting.

Ex: c:\database.mdb, c:\database_compacted.mdb

Sub Main()
Set Engine = CreateObject("JRO.JetEngine")
On Error Resume Next
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FULLPATHFILENAME", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FULLPATHFILENAME2"
If Err.Number <> 0 Then
Err.Clear
Else
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile "FULLPATHFILENAME"
fso.MoveFile "FULLPATHFILENAME2", "FULLPATHFILENAME"
Set fso = Nothing
End If
Set Engine = Nothing
End Sub

VBA Compact Access Database

There are some functions for compact an Access Database.

This one, requires to add a reference to Microsoft Jet y biblioteca Replication Objects X.X

Public Function CompactDB()

Dim Cjro As JRO.JetEngine
Set Cjro = New JRO.JetEngine
Dim cnn1 As String, cnn2 As String

' Cadena de conexión de origen
cnn1 = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data source=" & CurrentDb.Name & ";" & _
"Jet OLEDB:Engine Type = 5;"

' Cadena de conexión de destino
cnn2 = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data source=" & Left(CurrentDb.Name, Len(CurrentDb.Name) - 4) & "_compactada.mdb" & ";" & _
"Jet OLEDB:Engine Type = 5"

Cjro.CompactDatabase cnn1, cnn2

End Function