Mapping between XML:LANG and LCID in SQL Server full text search - sql-server

I have searched the whole internet and books and cannot find the mapping between xml:lang and lcid in full text search for multilingual content in SQL Server.
Here is a sample, not confirmed in any Microsoft doc:
Lcid xml:lang
1025 ar
1026 bg
1027 ca
1028 zh-TW
1030 da
1031 de
1033 en
1036 fr
I found some unofficial sources but I cannot be assured it works:
https://github.com/henrylearn2rock/lcids-xml-lang
https://github.com/Apress/pro-full-text-search-in-sql-server-2008/blob/5916c12181cc23becf26b6c99152b1a62c28f6e2/iFTS_Samples/Sample%20Database/Populate_Tables1.sql
Thanks

Related

SQL Server localdb RESTORE runs forever?

I'm using visual Studio 2019 community SQL Server localdb on Windows 10 Pro 202H. I've been trying 'restore' the WideWorldImporters database from WideWorldImporters-Full.bak (downloaded from GitHub) to my localdb instances without any success.
This has happened so far:
Qyery: (*** = My Username)
USE master
RESTORE DATABASE WideWorldImporters
FROM disk = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Backup\WideWorldImporters-Full.bak'
WITH MOVE 'WWI_Primary' TO 'C:\Users\***\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB\WideWorldImporters.mdf',
MOVE 'WWI_UserData' TO 'C:\Users\***\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB\WideWorldImporters_UserData.ndf',
MOVE 'WWI_Log' TO 'C:\Users\***\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB\WideWorldImporters.ldf',
MOVE 'WWI_InMemory_Data_1' TO 'C:\Users\***\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB\WideWorldImporters_InMemory_Data_1',
REPLACE
Message (pane) :
Processed 1464 pages for database 'WideWorldImporters', file 'WWI_Primary' on file 1.
Processed 53096 pages for database 'WideWorldImporters', file 'WWI_UserData' on file 1.
Processed 33 pages for database 'WideWorldImporters', file 'WWI_Log' on file 1.
Processed 3862 pages for database 'WideWorldImporters', file 'WWI_InMemory_Data_1' on file 1.
100% | No issues found
Executing query... (is running on and on)
Output (General) is empty
All the stuff notified in message window can be found in desitination folder:
WideWorldImportes_UserData.ndf (2 097 152 kb)
WideWorldImportes.mdf (1 048 576 kb)
WideWorldImportes.ldf ( 102 400 kb)
\WideWorldImportes_InMemory_Data_1\
filestream.hdr ( 1 kb)
\$FSLOG (empty )
\$HKv2
{1E6DC7E6-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 2 048 kb)
{3E231B6B-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 20 kb)
{4B9D83BE-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 2 048 kb)
{6E82296C-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 16 384 kb)
{6F44D507-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 1 024 kb)
{07FEB052-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 20 kb)
{7C4940C1-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 1 024 kb)
{9A77966E-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 4 096 kb)
{28CE0994-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 16 384 kb)
{63F1F945-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 2 048 kb)
{79B6C099-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 4 096 kb)
{122A2C90-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 16 384 kb)
{285FCA71-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 4 kb)
{421C57F0-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 4 096 kb)
{A54BA375-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 1 024 kb)
{C818BEE6-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 30 836 kb)
{CB6FF974-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 1 024 kb)
{F6F88B52-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 1 024 kb)
{F756E9B8-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.hkckp ( 1 024 kb)
Executing query... (still running, no changes in size of files for the last two hours)
This is where I'm now
and I'm getting mad
As you have gone for the option of RESTORE WITH REPLACE, it has overwritten existing WideWorldImporters database. As you have done restore with replace option, there could be uncommitted transactions, which it is trying to clean up. It will come back online after some time.
You have to be careful with REPLACE option. From MSDN
REPLACE Option Impact
REPLACE should be used rarely and only after
careful consideration. Restore normally prevents accidentally
overwriting a database with a different database. If the database
specified in a RESTORE statement already exists on the current server
and the specified database family GUID differs from the database
family GUID recorded in the backup set, the database is not restored.
This is an important safeguard.
The REPLACE option overrides several important safety checks that
restore normally performs. The overridden checks are as follows:
Restoring over an existing database with a backup taken of another
database.
With the REPLACE option, restore allows you to overwrite an existing
database with whatever database is in the backup set, even if the
specified database name differs from the database name recorded in the
backup set. This can result in accidentally overwriting a database by
a different database.
Restoring over a database using the full or bulk-logged recovery model
where a tail-log backup has not been taken and the STOPAT option is
not used.
With the REPLACE option, you can lose committed work, because the log
written most recently has not been backed up.
Overwriting existing files.
For example, a mistake could allow overwriting files of the wrong
type, such as .xls files, or that are being used by another database
that is not online. Arbitrary data loss is possible if existing files
are overwritten, although the restored database is complete.
You can read, how to come out of the restoring mode here: https://www.mssqltips.com/sqlservertip/5460/sql-server-database-stuck-in-restoring-state/

Looking up values within a range of cells

Suppose I have the following data table in Excel
Company Amount Text
Oracle $3,400 330 Richard ERP
Walmart $750 348 Mary ERP
Amazon $6,880 xxxx Loretta ERP
Rexel $865 0000 Mike ERP
Toyota $11,048 330 Richard ERP
I want to go through each item in the "Text" column, search the item against the following range of names:
Mary
Mike
Janine
Susan
Richard
Jerry
Loretta
and return the name in the "Person" column, if found. For example:
Company Amount Text Person
Oracle $3,400 330 Richard ERP Richard
Walmart $750 348 Mary ERP Mary
Amazon $6,880 xxxx Loretta ERP Loretta
Rexel $865 0000 Mike ERP Mike
Toyota $11,048 330 Richard ERP Richard
I've tried the following in Excel which works:
=IF(N2="","",
IF(ISNUMBER(SEARCH(Sheet2!$A$1,N2)),Sheet2!$A$1,
IF(ISNUMBER(SEARCH(Sheet2!$A$2,N2)),Sheet2!$A$2,
IF(ISNUMBER(SEARCH(Sheet2!$A$3,N2)),Sheet2!$A$3,
....
Where $A$1:$A$133 is my range and N2 is the "Text" column values; however, that is a lot of nested code and apparently Excel has a limit on the number of nested IF statements you can have.
Is there a simpler solution (arrays? VBA?)
Thanks!
Use the following formula:
=IFERROR(INDEX(Sheet2!A:A,AGGREGATE(15,6,ROW(Sheet2!$A$1:INDEX(Sheet2!A:A,MATCH("zzz",Sheet2!A:A)))/(ISNUMBER(SEARCH(Sheet2!$A$1:INDEX(Sheet2!A:A,MATCH("zzz",Sheet2!A:A)),N2))),1)),"")

SSIS Text file processing subset of rows

I have data in text files I am trying to process. When I connect to the data source using a flat file source it can only process a subset of the rows within the file. I am using SQL Server 2008 R2. Bellow is the sample data from a text file I am using.
PGH90961 Deep South Motors JAGUAR X-TYPE 2.2 D JAGUAR X400 JXX MZJAH511X6BE93589 R/C 2663 TNP990GP 55Q79510 1 0 16/02/2011MR D.J. JOHNSON NULL 0126675530 0827001220 E D.J. JOHNSON JOE De MAGGIO 178928
PGH90961 Deep South Motors FREELANDER DIESEL USED LANDROVER LUL MZLFA23B87H034028 7H034028 WCH432GP 55W74850 14 0 1
PGH90961 Deep South Motors JAGUAR X TYPE 3.0 Jaguar XT 3.0 JXT3.0 MZJAD53G25WE21791 R/C PBW641GP 55Q79630 1 0 16/02/2011MR D BUTCH 0116091630 0116301630 0834559627 E Mr.D BUTCH null JOE De MAGGIO 70091
PJP90961 Deep South Motors JAGUAR X TYPE 3.0 Jaguar XT 3.0 JXT3.0 MZJAD53G25WE21791 R/C PBW641GP 55Q77100 1 0 1
How can I possibly process all rows? Thank you.

Get state/province from geonames data?

I downloaded these databases for US and CA from GeoNames. The date looks like this:
5881639 100 Mile House 100 Mile House 51.64982 -121.28594 P PPL CA 02 0 917 America/Vancouver 2006-01-18
5881640 101 Mile Lake 101 Mile Lake 51.66652 -121.30264 H LK CA 02 0 917 America/Vancouver 2006-01-18
5881641 101 Ponds 101 Ponds 47.811 -53.97733 H PNDS CA 05 0 18 America/St_Johns 2006-01-18
I want to use this data for a city-picker, but I want to display to province or state beside it. Doesn't look like this data contains that information. Is there some way to retrieve that? Or is there a better DB that includes that?
You use the data in the columns for the admin codes these are actually ids that link to the admin codes table (there are separate data sets available for the admin codes) it is very straightforward.
Check the Geonames forums for more info.
http://forum.geonames.org/
Use the datasets here: geocoder.ca which include city name and state / province name in the same file.
If you want to stick with your data, you can use Google's Geocoding API, as in the first answer here:
Google Maps: how to get country, state/province/region, city given a lat/long value?
to get information based on latitude and longitude. This will be a lot of work, though, especially for a city-picker.

Sybase: what device names does a database use?

Does anyone know how I can query the database to find what devices a database uses?
There is the sysdatabases table and the sysdevices table but I don't know how to link them
Anyone know?
The best way is to run sp_helpdb against the database you're interested in:
1> sp_helpdb tempdb2
2> go
... other stuff here...
device_fragments size usage created free kbytes
------------------------------ ------------- -------------------- ------------------------- ----------------
tempdb2data 2048.0 MB data only Dec 17 2008 11:42AM 2086568
tempdb2log 2048.0 MB log only Dec 17 2008 11:42AM not applicable
tempdb2log 2048.0 MB log only Dec 17 2008 11:42AM not applicable
tempdb2data 2048.0 MB data only Dec 17 2008 11:43AM 2088960
tempdb2log 4096.0 MB log only Dec 17 2008 11:44AM not applicable
--------------------------------------------------------------
log only free kbytes = 8355836
1 Just a note re your first question. If you USE database first, you will get even more detail in the report.
2 Do you still need the second question answered, how to link sysdatabase and sysdevices, as in, are you writing queries against the catalogue ? If so, I need your ASE version, the answers are different.

Resources