SQL Server 2008 - Rule "Previous release of Microsoft Visual Studio 2008" failed

by pietman 15. September 2011 10:35

Although you already have VS2008 SP1 installed.

Fix:

start -> run -> "cmd"

Setup /ACTION=install /SkipRules=VSShellInstalledRule

you will still get an error but it installs fine.

 

The SQL Server 2008 installer is checking the HKLM\SOFTWARE\Microsoft\DevDiv\XXX\Servicing\9.0\SP reg keys to tell if SP1 is installed. If you inspect those keys and find any SP keys with the value “0,” that is your road block.

 

Tags:

Errors | SQL SERVER

Throwing Errors in SQL stored procedures

by pietman 13. September 2011 12:41

Best way to do it is as follows:

create function dbo.throwError()
returns nvarchar(max)
as
begin
    return cast('Error here.' as int);
end

and it will throw the following error:

Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'Error here.' to data type int.

Tags:

Errors | SQL SERVER

renaming database, kill database connections etc

by pietman 21. December 2010 09:06

 Trying to rename a database or taking it offline?
Getting the following 2 errors:

Msg 5061, Level 16, State 1, Line xxx

ALTER DATABASE failed because a lock could not be placed on database 'dbname'. Try again later.

 

Msg 952, ...
Database is in transition ...

 


 

Here is the solution:

The following will find the processes that prevents you from modifying the database. 

 

--run the next line only once
--sp_addlinkedserver @server = 'LOCALSERVER', @srvproduct = '', @provider = 'SQLOLEDB', @datasrc = 'colhpasql002'

SELECT * FROM OPENQUERY(LOCALSERVER, 'EXEC sp_who') WHERE dbname = 'HIV_STI_DataWarehouse'


The Following will find and kill the locking processes on a database ... change 'HIV_STI_DataWarehouse' to your database name

USE master

GO 

 

SET NOCOUNT ON

 

DECLARE @DatabaseName varchar(50)

DECLARE @DynamicSQL varchar(8000)

DECLARE @KillCount smallint

 

SET @KillCount=0

SET @DynamicSQL = '' 

Set @DatabaseName = 'HIV_STI_DataWarehouse'

 

IF db_id(@DatabaseName) < 4

BEGIN

PRINT 'Target cannot be a system database'

RETURN

END

 

SELECT @DynamicSQL=coalesce(@DynamicSQL,',' )+'kill '+convert(varchar, spid)+ '; '

FROM master..sysprocesses

WHERE dbid=db_id(@DatabaseName) 

PRINT(@DynamicSQL)

 

IF LEN(@DynamicSQL) > 0

BEGIN

EXEC(@DynamicSQL)

SELECT @KillCount = COUNT(1) FROM master..sysprocesses

WHERE dbid=db_id(@DatabaseName)

END 

 

 

 

 

Tags: ,

Errors | SQL SERVER

About ...

pietman celliersPietman Celliers
Bitlink  Ltd
bitlinkit.com