Wednesday, November 14, 2012

How to switch cluster nodes in Windows 2003 with SQL 2005 installed

This is not the most modern products anymore. Anyway I went in to a problem where we were forced to switch the old server to new one.
If some of you out there need to do it I describe the steps here. Not in detail but some aspect to think about.

  • Add the new servers to the cluster, so in our case we had now a 4 node cluster. Be sure that the disks also are shred to the new server.
  • Expand the SQL installation to the new servers. This is done from the first cluster node. In add remove program you change the SQL installation. Chose the correct instance and add the new server. One important thing when doing this is to NOT be logged on with the same account that you install with on the new servers. The Remote execution will fail if you do. When the installation is success SQL is now installed on the new servers.
  • Install same SQL servicepack and patches as the old servers. Run also those from the active cluster node.
  • If you need any SQL client tool on the new nodes you have to install this one by on respective server and also the servicepack and patches for those.

If everything went well it’s now some issues to take care of :-)

If you have used a certificate in SQL be sure this is installed on the new servers. If not the engine would not start. You receive an error like: Unable to load user-specified certificate. The server will not accept a connection. You should verify that the certificate is correctly installed. See "Configuring Certificate for Use by SSL" in Books Online.
In our case there was some old ssl certificate added that was not even in use anymore. I tried to remove the string in register HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\SuperSocketNetLib\Certificate but that was not so straight forward as I thought. When failing over the resource it added back the old certificate key anyway. After some testing I recognized that it has to be done on the active nodes in the cluster before you move the resources. In our case the certificate was not used so I just leaved the value blank.

I also had some issues with the transaction cordinator. It was impossible to start it on the new servers.  In the windows log I got some errors like MS DTC has detected that a DC Promotion has happened since the last time the MS DTC service was started and MS DTC Transaction Manager start failed. LogInit returned error 0x8007000e. Our clusternodes was also domain controllers. And the new one had been added as new domain controllers as well (I know it’s not a nice solution). I found a KB on this After change the register permission on for NETWORK SERVICES account it worked well.

Service account cant be verified
I you have a trailingspace in the clustergroups name where SQL reside you get a error says that the account you type for SQL service is wrong or can´t be verified. 
"SQL Server could not validate the service accounts. Either the service accounts have not been provided for all of the services being installed, or the specified username or password is incorrect." See for more info.

Hope this can help someone :-)

Wednesday, September 19, 2012

SET SPN on the SQL service account

It´s not so easy to find a clear roule how this shall be done. But this is what I use and it works.
You have to setup three SPN-s, Full FQDN against the port (be sure to use static), FQDN against the instancename and a third one against the Netbios name.


For the analysis service those two are needed


In some situation also the browser needs to be fixed.


Beyond of the Kerberos SPN setting you also need to set the serviceaccount trusted for delegation in active directory. Client will use Kerberos anyway but in some situation
where you have more then two machines involved in the authentication chain this is necessary.

Monday, September 3, 2012

Query Excel and text files from SQL

Here is some different ways to query an excel sheet or textfile.

'Data Source=G:\test.xls;Extended Properties=Excel 8.0')...[sheetname$]

'Excel 8.0;Database=G:\test.xls', [sheetname$])

SELECT * into import FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=G:\test.xls', 'SELECT * FROM [sheetname$]')

select * from OpenRowset('MSDASQL',
'Driver={Microsoft Text Driver (*.txt; *.csv)}; DefaultDir=C:\Temp;Extended properties=''ColNameHeader=True;Format=CSVDelimited;''','select * from test.csv')

SELECT a.* FROM OPENROWSET( BULK 'c:\test\test.txt',
FORMATFILE = 'c:\test\formatfil.fmt') AS a;

Most of the time I have test to query textfiles from OPENROWSET it is difficult to delimiter the columns in the text file. I have never seen the Format=CSVDelimited settings having any affect. But the grate site pointed out that you must set this in the registry on the server. And this works well for me. See example below. I wonder why the setting is available in the Extended Properties then?? At least I have never got it to work. But that says nothing :-)

The delimiter can be specified in the registry at the following location:

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Jet \ 4.0 \ Engines \ Text 
"Format" = "TabDelimited" or "Format" = "Delimited(;)"

Thursday, August 2, 2012

Where to find the systemdatabases on installation media?

Those files can be usefull, in the installation media they reside here:

Monday, May 7, 2012

setup.rll is either not designed to run on Windows or it contains an error.

Hi SQL folks. A couple of time when I have done installation of SQL 2008 R2 with unpacked iso image the database engine installation has failed. And it tells you that some of the msi image is corrupt. Im nut sure if there is any problem when unpacking the iso image. Anyway after this has happened it’s not possible to uninstall the corrupt SQL installation. You will receive an error like this:

Application popup: setup.exe - Bad Image : C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\SQLServer2008R2\resources\1033\setup.rll is either not designed to run on Windows or it contains an error. Try installing the program again using the original installation media or contact your system administrator or the software vendor for support.

First time I saw this I did not solve it. So I have to let the windows guys reinstall the operating system. But today when same error come up googled the error message and saw that Alex Siow solved it just with copying the setup.rll files from the installation media path: 1033_ENU_LP\x64\Setup\sqlsupport_msi\PFiles\SqlServr\100\Setup\fe72iemr\Res\1033 to Program Files\Microsoft SQL Server\100\Setup Bootstrap\SQLServer2008R2\Resources\1033 and it also worked for me. Yes!

Have a nice day everyone.

Friday, January 13, 2012

How to move a database to a lower version level

It easier than you think.
1. In the source SQL server you right klick on the database you wich to move or copy. Chose “Tasks”, then “Generate Scripts.." Run this wizart to export all objects in the database. Unde advanced chose to save it for SQL 2005 or whatever version it is.
2. On the destination server run the script to create the database and all objects in it.
3. Now we have an empty database. Let’s then export import the data. For this we use the BCP utility. On the source server run this script in a query window.(thanks for this script Madhivanan)

declare @tables table(table_name varchar(100))
insert into @tables
select name from sysobjects where xtype ='u'
declare @table_name varchar(1000)
select @table_name=min(table_name)from @tables
while @table_name>''
Declare @str varchar(1000)    
set @str='Exec Master..xp_Cmdshell ''bcp '+db_name()+'.dbo.'+@table_name+' out C:\temp\test\'+@table_name+'.txt -T -c'''
select  @table_name=min(table_name) from @tables where table_name>@table_name
print @str

4. Now we export all the data to textfiles. Every table has a textfile each. Let’s import them now.
5. On the target server run same scrip again but change out to ín instead. Be sure to use the correct path to the files also.
That’s all, easy and quite fast way to go.
Joel Sjöö