| John Peterson 2002-11-11, 5:23 pm |
| (SQL Server 2000, SP2)
Hello, all!
I'm trying to leverage the master..syslanguages in a rather undocumented
(and, I'm sure, unsupported ;-) way. Nevertheless, I thought I would try
and solicit some help. :-)
I am attempting to "extend" the master..syslanguages table to include more
language specifications than are natively handled by SQL Server. However, I
really don't want SQL Server to do anything with this information, other
than set the session's @@LANGID/@@LANGUAGE system variables accordingly (I'd
be happy to keep the "bulk" of the information with the langid=0 English
setting).
For example, if I run the following script:
/* NOTE: Ensure that you don't have any languages with a langid > 32 before
you proceed. */
--select * from master..syslanguages where langid > 32
execute sp_configure 'allow updates', '1'
reconfigure with override
go
delete master..syslanguages
where langid > 32
go
insert into master..syslanguages
select 1033 as langid,
dateformat,
datefirst,
upgrade,
N'en-US' as name,
N'en-US' as alias,
months,
shortmonths,
days,
lcid,
msglangid
from master..syslanguages
where langid = 0 /* us_english */
execute sp_configure 'allow updates', '0'
reconfigure
go
This appears to add the language successfully. I can test it from the SQL
Server level by doing:
set language 'en-US'
And when I do:
select @@LANGID, @@LANGUAGE
I get the values that I would expect.
Trying to leverage this from VBScript, I wrote the following code (you can
cut and paste this to a Test.vbs file):
Dim cn
Dim rs
Dim sConnect
Dim sCulture
sCulture = "en-US"
sConnect = "Provider=SQLOLEDB;Data Source=(local);User
ID=sa;Password=;Initial Catalog=tempdb;Language=" & sCulture & ";"
Set Cn = CreateObject("ADODB.Connection")
Call cn.Open(sConnect)
Set rs = cn.Execute("select @@LANGID, @@LANGUAGE")
If (Not rs.EOF) Then
MsgBox("@@LANGID: " & rs(0) & ", @@LANGUAGE: " & rs(1))
End If
Call rs.Close()
Call cn.Close()
Set rs = Nothing
Set cn = Nothing
Note the addition of a "Language" specifier in the connection string. This
also appears to work as expected.
However, if I add a *lot* of new languages to master..syslanguages, there
are some langid values that seem to cause ADO some "heartburn". For
example, on my system, if I try a langid value of 11111, 12000, or some
other arbitrary smallint value (instead of 1033), I'll get a VBScript error:
Default date order 'X' for language en-US is invalid. Using mdy instead.
What's weird, is that the character for 'X' is usually something in some
other language. And, depending on the langid I use, the character is
different, as if ADO is potentially using a different size to store this
variable and using a lookup function?
I don't have the problem from SQL Server if I use the "SET LANGUAGE" syntax,
so I think it's a function of the ADO objects/driver. I have the "latest"
updates, according to Microsoft's Windows Update. I have seen this problem
(though with different langid values) under Windows XP Professional and
Windows 2000 Professional.
I'm wondering if there's a relatively "safe" range of langid values that I
can use? I don't *seem* to have the problem in the "lower" values (like <=
256), but I had hoped to use the actual LCID value for the langid.
Again, I appreciate that this isn't wholly "kosher", but I sure would covet
any thoughts, ideas, recommendations as to how I might get this to work.
:-)
Regards,
John Peterson
|