Tuesday, July 9, 2013

Much Needed Crystal Reports Improvements

  1. Upgrade code
    Currently, code is VB6.  Should be upgraded to .NET to accept nullable parameter variables.
  2. Text Definition Files.
    RPT files are currently in binary format. This excludes report generation using code generation tools, and fixing Crystal Report nuances by editing the definition file.
  3. Modify Order Of Parameters on Prompt Screen.
    You define Parameter A and then you define Parameter B, and setup your selection formulas. Then, you decide that Parameter B should come before Parameter A on the parameters prompt screen that crystal shows before printing the report. You're in trouble. There is currently no way to modify the order of the parameters prompt. You will have to remove references of Parameter A from all formulas and then remove the Parameter. This will bring Parameter B first. Then you add Parameter A again and setup again all formulas you removed.

Restoring an SQL Server Database that is in use

Often we have to restore a database in sql server but that is in use.  The script below enables restore of database even if it is use. 


Adjust for your needs and use at your own risk.


USE [master]
GO
if exists (select * from sysdatabases where name='MY_DATABASE') begin
print 'taking database MY_DATABASE to single mode'
ALTER DATABASE MY_DATABASE SET SINGLE_USER WITH ROLLBACK IMMEDIATE
end
GO
if exists (select * from sysdatabases where name='MY_DATABASE')
begin
print 'drop MY_DATABASE'
DROP DATABASE MY_DATABASE
end
go
USE [master]
GO
RESTORE DATABASE MY_DATABASE FROM
DISK = N'C:\MSSQL\Backup\MY_DATABASE_backup.bak' WITH FILE = 1,
MOVE N'DataTemplateSQL_dat' TO N'c:\MSSQL\DATA\MY_DATABASE.mdf',
MOVE N'DataTemplateSQL_log' TO N'c:\MSSQL\DATA\MY_DATABASE.LDF',
NOUNLOAD, STATS = 10
GO
use MY_DATABASE
go