0
votes

I read a heavy data from csv file to sql server table,but i cant encode that data with this encode code:

Encoding.GetEncoding(1256)


I read this link and notice this:
https://msdn.microsoft.com/en-us/library/ms186356.aspx


The code 1256 is Arabic Encode,and i want to change my database collation with under solution:

1

1 Answers

0
votes

You are getting this error because you have some active connections to your database.

Alter database statement needs to obtain schema lock on the database, but if there are any active connections it will fail hence the error you are getting.

Alternatively you can do the following:

Use master
GO

ALTER DATABASE [behzad]
SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO

USE [behzad];
GO

USE master;
GO

ALTER DATABASE [behzad] COLLATE Arabic_100_CI_AS_KS
GO

ALTER DATABASE [behzad]
SET MULTI_USER;
GO