Categories
Babbling Tips

How to ruin a very good site reputation !

I know that in recent times, I am kind of feeling more sensitive towards users experience in general, weather it is @ customer support for any item or @ email system … or this time @ one of my favorite download site (at least it used to be but not anymore).

For years I have used Download.com as my download site for windows application. Time to time I have used even reviews from CNET to lean about new/existing software .. but my recent experience has left a bad test in mouth to say, and I think I will not download from them ever Broken heart. Till now, when ever you want to download from this site all you had to do was to just search for that software, download it using link provided by the site and install the software.

But today when I tried this site to download “Revo Uninstaller” (an uninstaller application) instead of getting simple EXE, I got a custom installer designed by CBS Interactive (owner of CNET), it even has digital certificate from MSFT too so it “feels” more genuine. But I think it is wolf in disguise of sheep Annoyed (I am not sure about analogy but I guess you got the point).

So, this is how it begun … I downloaded an installer for “Revo Uninstaller” from www.Download.com and it gave me some 620Kb installer. As I begun installation using this installer, I have following screens …

CNET_1

First step is to indicate that I will be downloading and installing Revo Uninstaller.

Categories
SQL Server Tips

Policy Based Management in SQL Server

This great feature was introduced in SQL Server 2008 and since then it has been considered as one of “standard” method to administer database proactively. As the name suggests, it allows DBAs to create various policies to enforce certain rules to single database, to group of databases or to whole server… for example default database backup location has to be some particular drive or every new database has to be in full recovery mode or each SP that are created and that will be created has to have prefix “USP_” etc.

It is very common issue of collaborative database development that developers like to keep follow their own naming convention then industry standards or MSFT recommendations for database objects. And they usually choose proper names for any objects they create, based on function / purpose of that object. But sometimes they like to choose name which could effect how SQL Server Query Execution planner behaves and you might see performance impact. For example in case of Stored Procedures, use of prefix SP in front of the stored procedure name. Now, I am not an expert in performance tuning but I know basic thing that it causes Query Execution planner to look into system stored procedure list at first because SP keyword is reserved for system stored procedures.

So instead of routinely monitoring any change made by devs and modifying / rolling back their change for such a silly name, it is far more convenient to have SQL Server watch for any thing like that and if such event occurs simply fail the execution and let developer know about this mistake. And this is exactly what I am going to demo here Smile

Policy Based Management (aka PBM) is made of 3 components. Facets, Conditions and Policies. And the order it works is, you use existing facet in condition and based on that condition you create a policy to be implemented on either single database or whole server.

1) Facets : They are kind of hard to explain by simple definition. Think of it as a class of .NET which exposes various properties. For example, database has different properties like Size, Name, Status, Owner, etc.… And you can use any of these properties to define condition. See this post for more detailed definition of Facets. By default there are number of pre-defined facets exist in SQL Server and there is no option to create user defined facet. A typical facet for Store Proc looks something like below,

Categories
Bugs Tips

Error Deploy01234: The target database schema provider could not be determined. Deployment cannot continue.

This was the error that I was getting when i was trying to deploy our database project to one of our test system in a batch script. To me it was a bit surprise because I had done same process many times in past and it has worked just fine. But today I spent hefty amount of time to resolve this issue. Whole error that I was getting was  something like below,

 

—— Deploy started: Project: Database, Configuration: Debug Any CPU ——

C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.TSqlTasks.targets(120,5): Error Deploy01234: The target database schema provider could not be determined.  Deployment cannot continue.

   Done executing task “SqlDeployTask” — FAILED.

  Done building target “DspDeploy” in project “TheDatabase.dbproj” — FAILED.

Done executing task “CallTarget” — FAILED.

Done building target “DBDeploy” in project “TheDatabase.dbproj” — FAILED.

Done building project “TheDatabase.dbproj” — FAILED.

Build FAILED.

 

Categories
SQL Server Tips

Database Snapshots … The Good, Bad and Ugly

In SQL Server 2005 MSFT introduced very new feature … Database Snapshots … which is basically a read-only view of database at the time when snapshot was taken. Just as a side note…even at the time this feature was introduced in SQL Server, other age old DBMSes like Oracle and DB2 were already offering similar feature in their systems. Database Snapshots can prove really useful if used wisely or can bite you back if used without any thoughts … hence … The Good, bad and ugly … Open-mouthed smile

Another note before starting … unfortunately Database Snapshots are kind of toys for rich only Broken heart … which means you have to have Enterprise edition to use this feature. But since I have developer edition … I am more like a lottery winner Winking smile … because all Enterprise features are available in Developer edition … with that being said … let’s prepare staging environment.

I have a test database with few sample tables that I have derived from AdventureWorks tables. I created this database into a temp HDD created using one of my favorite RamDisk software. Which gives me ability to blow up that drive without any issue at any time (which exactly what I will do at the end of this demo in the Ugly part Open-mouthed smile). But say if you don’t have enough RAM you can use USB thumb drive as a place to restore database backup. I restore database with following command …

Categories
Installer Tips

Advance MSI creation … Part I

Couple of months back I created a post about using Windows Installer Project in VS 2010 and how to create MSI from that. At that time I had very simple requirement to work on, create an installation package that just installs our product … recently that requirement got changed a bit and now I am suppose to perform some post installation processes once installation is done and to make things seamless, I have to include them as part of installation process (from my experience, only thing that doesn’t change is change in requirements Open-mouthed smile … which is kind of good … because as soon as requirements stop changing … you are out of job)

But before we dig deep, few things we need to get familiar with…

Custom Actions: from MSDN,

Custom actions are a Windows Installer feature that allows you to run code at the end of an installation to perform actions that cannot be handled during installation. The code can be in the form of a .dll, .exe, script, or assembly. For example, you might want to create a local database on the target computer during installation. You could create an executable file that creates and configures the database, then add that executable file as a custom action in your deployment project.

Categories
SQL Server Tips TSQL

RAISERROR with TRY … CATCH block

RAISERROR is one of the most efficient method to raise user created exception based on various situations. And TRY CATCH block is perhaps the most known method for exception handling in any programing language. But it is a bit tricky to use both of them together due to manner in which they transfer control to next command.

Following the examples show typical behavior in different cases.

TRY CATCH with Error Severity <= 10. As you know error severity <= 10 are actually informational messages and they don’t raise any error.

[sql]
begin try
select ‘from Try block 1’
raiserror(‘Error is Raised’ ,10 — Severity <= 10 ,1 ,N’number’ ,5) with log
select ‘from Try block 2’
end try

begin catch
select ‘from catch block’
end catch
[/sql]
 

TRY_CATCH_1

Categories
DOS Tips

File Integritry verfication … using File Checksum Integrity Verifier

Lets say you download a file from internet and you want to make sure that this file’s source is legitimate (say you just downloaded new ISO of Ubuntu from their site). Or in another case you want to make sure that there is no corruption in file that you just downloaded from internet (now you may argue that why bother ? Can’t you just download that file again ? … but sometimes it’s not that simple … and that’s how it works in office bureaucracy Open-mouthed smile) … in both of these cases usually you can ask for hash key generated using either MD5 or SHA-1 algorithms from person who sent you that file and compare those keys with key generated by you and if that matches then everything is good … and if it doesn’t then something funny is going on. In fact, today it is very common practice by many companies to provide MD5 and/or SHA-1 hash keys for their software to make sure that they are not tempered with.

And File Checksum Integrity Verifier aka FCIV is a mouthful name of a tiny utility by MSFT. Sole purpose of this utility is to create or compare file integrity using MD5 or SHA-1 hashing algorithms. First step for that is of course to get FCIV from MSFT Download Center. Only issue (!!) is there is no GUI for this utility, so you will need to use terminal to run this utility.

Following is copy from help of this tool,

//
// File Checksum Integrity Verifier version 2.05.
//

Usage:  fciv.exe [Commands] <Options>

Commands: ( Default -add )

        -add    <file | dir> : Compute hash and send to output (default screen).

                dir options:
                -r       : recursive.
                -type    : ex: -type *.exe.
                -exc file: list of directories that should not be computed.
                -wp      : Without full path name. ( Default store full path)
                -bp      : specify base path to remove from full path name

        -list            : List entries in the database.
        -v               : Verify hashes.
                         : Option: -bp basepath.

        -? -h -help      : Extended Help.

Options:
        -md5 | -sha1 | -both    : Specify hashtype, default md5.
        -xml db                 : Specify database format and name.

To display the MD5 hash of a file, type fciv.exe filename