Wednesday, March 28, 2012
Problems in SQL, Updating many rows at once
I have a person table. The relavent columns are:
PersonID INT
LastName VARCHAR(30)
LastNameSndx CHAR(4)
I'm almost embarressed to ask considering my SQL expertise, but...
I need to take the SOUNDEX of the LastName and put that value in the LastNameSndx column. So I fire off this SQL:
Update Person Set LastNameSndx = SOUNDEX(LastName);
It takes forever. I start tweeking the SQL to commit every 500 records or so. Still takes a long time. I then notice what is happening. The SQL is taking the SOUNDEX of the LastName of the first record, apply it to ALL the records, then taking the SOUNDEX of the LastName of the second records, then updating it to ALL the records, etc.
This is not SQL as I understand it.
What am I doing wrong here?Hi!
> It takes forever. I start tweeking the SQL to commit every 500 records or
so. Still takes a long time. I then notice what is happening. The SQL is
taking the SOUNDEX of the LastName of the first record, apply it to ALL the
records, then taking the SOUNDEX of the LastName of the second records, then
updating it to ALL the records, etc.
>
How did you notice this? This is really strange, I've never heard of
something like this.
--
Dejan Sarka, SQL Server MVP
Please reply only to the newsgroups.|||I attempted the same thing and I am not seeing the same behavior. Not sure
what is happening in your case.
Rand
This posting is provided "as is" with no warranties and confers no rights.
Problems in SQL, Updating many rows at once
I have a person table. The relavent columns are:
PersonID INT
LastName VARCHAR(30)
LastNameSndx CHAR(4)
I'm almost embarressed to ask considering my SQL expertise, but...
I need to take the SOUNDEX of the LastName and put that value in the LastNam
eSndx column. So I fire off this SQL:
Update Person Set LastNameSndx = SOUNDEX(LastName);
It takes forever. I start tweeking the SQL to commit every 500 records or so
. Still takes a long time. I then notice what is happening. The SQL is takin
g the SOUNDEX of the LastName of the first record, apply it to ALL the recor
ds, then taking the SOUNDEX
of the LastName of the second records, then updating it to ALL the records,
etc.
This is not SQL as I understand it.
What am I doing wrong here?Hi!
quote:
> It takes forever. I start tweeking the SQL to commit every 500 records or
so. Still takes a long time. I then notice what is happening. The SQL is
taking the SOUNDEX of the LastName of the first record, apply it to ALL the
records, then taking the SOUNDEX of the LastName of the second records, then
updating it to ALL the records, etc.
quote:
>
How did you notice this? This is really strange, I've never heard of
something like this.
Dejan Sarka, SQL Server MVP
Please reply only to the newsgroups.|||I attempted the same thing and I am not seeing the same behavior. Not sure
what is happening in your case.
Rand
This posting is provided "as is" with no warranties and confers no rights.
Monday, March 12, 2012
problems about displaying chinese and mislocation of controls
1. I have problems on displaying chinese on reporting services.
e.g. §Cˉ×a′oà-J′?3??h?o(¤??)
The data type of the fields is char. Is it possible to display chinese using this database setting but not setting the data type to nvarchar?
2. On the other hand, there is mislocation of the controls. If I put a textbox on another textbox, one of the textbox will not be in the orginal location but in somewhere nearby. The same situation appears for the case of images. How can I "lock" the location of the controls?
I almost forgot I am assuming you know the Chinese alphabet is more than 2000 characters compared to the 26 characters Latin. I don't see how you can render Chinese with Char, you need Nvarchar or Nvarchar(max) with the version of Chinese you need because there are about six defined in SQL Server. You can use collation for the database table and column, the report dataset data option property and the international section of the table and text box. The later just change the collation of the ReportServerDB and the ReportServerTempDB. But clean collation in your tables and columns with the stored procedure will take care of it. Hope this helps.
|||
There is nothing happen when I set any collation in MS VS. As other applications are using the same database, I can't change the datatype into nvarchar.
Is nvarchar the only solution to the problem?
|||(Is nvarchar the only solution to the problem?)
Nvarchar only tells SQL Server the data is not ASCII but Unicode it is the collation that tells SQL Server what code page to use and sort order which is very important with Chinese. You can create a View with Chinese collation and Nvarchar, then add the collation in the stored procedure run a search for collation precedence in the BOL.