ERROR FIX performance counter registry hive consistency in SQL Server 2008 installation

Error “performance counter registry hive consistency” while installing SQL Server 2008 is really frustrating error.  I have installed Microsoft SQL Server 2008 Evaluation Edition quite a few times but this is first time I got error “performance counter registry hive consistency”.  This error itself shows that there is a problem in registry of performance  counter so the prime question is, how to resolve this issue? There may be few different ways but I use “LodCTR.exe” file.

LodCTR is a Microsoft Windows Operating system process file and I used it with \R attribute which will rebuild the performance counter registry strings and information from scratch based on the current registry settings and backup INI files.

So making long story short, open your dos prompt, may be with following steps:

Start menu->Run->type CMD->press enter key

It will open command prompt and you can run

C:\>lodctr /R

Give it a time and then try installing again, hopefully you will be able to install Microsoft SQL Server 2008.

Reference: Ritesh Shah
http://www.sqlhub.com
Note: Microsoft Books online is a default reference of all articles but examples and explanations prepared by Ritesh Shah, founder of
http://www.SQLHub.com
Advertisements

Cannot generate SSPI context (Microsoft SQL Server) in SQL Server 2005

You might face error “Cannot generate SSPI context” while login to your SQL Server 2005 from SQL Server Management Studio. This is really annoying error. Basically the root cause of this error is current windows user doesn’t have proper permission.

This error occurs only when you are trying to login with “Windows Authentication”. You have two options.
1.)    Login with your SQL Server authentication, if you have id/pass
2.)    Set proper permission for your user.

As a simple option, you can right away switch to SQL Server Authentication. For digging more about permission issue of your windows user, have a look at some of the following link from Microsoft website.

Reference: Ritesh Shah
http://www.sqlhub.com
Note: Microsoft Books online is a default reference of all articles but examples and explanations prepared by Ritesh Shah, founder of
http://www.SQLHub.com

String or binary data would be truncated. Msg 8152, Level 16, State 14, Line 1. The statement has been terminated.

Once I have been asked by my junior ASP.NET programmer, why this error comes? There was a pretty much clear reason for that when you are trying to insert the value bigger than the field limit. First let us see how we can replicate the error.

–create table for demo

CREATE TABLE StringTest

(

Name varchar(5)

)

GO

–since we have varchar limit of 5 character in Name field

–we should enter the value less than equal to 5

INSERT INTO StringTest VALUES(‘Rites’)

SELECT * FROM StringTest

GO

–if we try to insert value greater than 5 character

–we will face an error like below.

–Msg 8152, Level 16, State 14, Line 1

–String or binary data would be truncated.

–The statement has been terminated.

INSERT INTO StringTest VALUES(‘Ritesh’)

SELECT * FROM StringTest

GO

–I STRONGLY SUGGEST you handle this kind of validation from front end itself

–even if you are tempted to do so in SQL Server, you can have two ways of doing it

–1.)

INSERT INTO StringTest VALUES(Left(‘Ritesh’,5))

SELECT * FROM StringTest

GO

–2.)

SET ANSI_WARNINGS OFF

INSERT INTO StringTest VALUES(‘Ritesh’)

SELECT * FROM StringTest

GO

–SET ANSI_WARNINGS OFF statement will automatically truncate the value

–and took ‘Rites’ from the given string and eliminate last character

–however, it is not a proper way to do so.

Hope you have enjoyed this tip.

Reference: Ritesh Shah
http://www.sqlhub.com
Note: Microsoft Books online is a default reference of all articles but examples and explanations prepared by Ritesh Shah, founder of
http://www.SQLHub.com