-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f76caa
commit 86e7c33
Showing
3 changed files
with
276 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# SNOMED CT DATABASE | ||
|
||
MSSQL SQL Scripts to create and populate a MSSQL database with a SNOMED CT terminology release | ||
|
||
## Minimum Specification | ||
|
||
- MSSQL 2008 | ||
|
||
# Creating the SNOMED CT DB schema on MS SQL | ||
|
||
- Create an empty DB and execute manually script create-database-mssql.sql against it | ||
|
||
## Diffences from the PostgreSQL version | ||
|
||
- TSQL check for table presentse | ||
- Changes `uniqueidentifier` for `uuid` | ||
|
||
## Manual Installation | ||
|
||
- Unpack Full version of SNOMED CT files | ||
- Copy import.bat into root folder where Full SNOMED CR files were updacked (the root has "Documentation" and "Full" folders only) | ||
- execute import.bat | ||
- import.sql script will be generated. Execute it againt desired MS SQL DB | ||
|
||
You may use sqlcmd to execute import.sql | ||
sqlcmd -b -I -S [server IP/name, port] -d [DB name] -U [User] -P [Password] -i import.sql | ||
|
||
Note: If you recieve message that "... Operating system error code 5(Access is denied.)" - please follow https://stackoverflow.com/questions/14555262/cannot-bulk-load-operating-system-error-code-5-access-is-denied |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
/* create the Full S-CT data tables */ | ||
|
||
|
||
IF EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'curr_concept_f') DROP TABLE curr_concept_f; | ||
create table curr_concept_f( | ||
id varchar(18) not null, | ||
effectivetime char(8) not null, | ||
active char(1) not null, | ||
moduleid varchar(18) not null, | ||
definitionstatusid varchar(18) not null, | ||
PRIMARY KEY(id, effectivetime) | ||
); | ||
|
||
IF EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'curr_description_f') DROP TABLE curr_description_f; | ||
create table curr_description_f( | ||
id varchar(18) not null, | ||
effectivetime char(8) not null, | ||
active char(1) not null, | ||
moduleid varchar(18) not null, | ||
conceptid varchar(18) not null, | ||
languagecode varchar(2) not null, | ||
typeid varchar(18) not null, | ||
term text not null, | ||
casesignificanceid varchar(18) not null, | ||
PRIMARY KEY(id, effectivetime) | ||
); | ||
|
||
IF EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'curr_textdefinition_f') DROP TABLE curr_textdefinition_f; | ||
create table curr_textdefinition_f( | ||
id varchar(18) not null, | ||
effectivetime char(8) not null, | ||
active char(1) not null, | ||
moduleid varchar(18) not null, | ||
conceptid varchar(18) not null, | ||
languagecode varchar(2) not null, | ||
typeid varchar(18) not null, | ||
term text not null, | ||
casesignificanceid varchar(18) not null, | ||
PRIMARY KEY(id, effectivetime) | ||
); | ||
|
||
IF EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'curr_relationship_f') DROP TABLE curr_relationship_f; | ||
create table curr_relationship_f( | ||
id varchar(18) not null, | ||
effectivetime char(8) not null, | ||
active char(1) not null, | ||
moduleid varchar(18) not null, | ||
sourceid varchar(18) not null, | ||
destinationid varchar(18) not null, | ||
relationshipgroup varchar(18) not null, | ||
typeid varchar(18) not null, | ||
characteristictypeid varchar(18) not null, | ||
modifierid varchar(18) not null, | ||
PRIMARY KEY(id, effectivetime) | ||
); | ||
|
||
IF EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'curr_stated_relationship_f') DROP TABLE curr_stated_relationship_f; | ||
create table curr_stated_relationship_f( | ||
id varchar(18) not null, | ||
effectivetime char(8) not null, | ||
active char(1) not null, | ||
moduleid varchar(18) not null, | ||
sourceid varchar(18) not null, | ||
destinationid varchar(18) not null, | ||
relationshipgroup varchar(18) not null, | ||
typeid varchar(18) not null, | ||
characteristictypeid varchar(18) not null, | ||
modifierid varchar(18) not null, | ||
PRIMARY KEY(id, effectivetime) | ||
); | ||
|
||
IF EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'curr_langrefset_f') DROP TABLE curr_langrefset_f; | ||
create table curr_langrefset_f( | ||
id uniqueidentifier not null, | ||
effectivetime char(8) not null, | ||
active char(1) not null, | ||
moduleid varchar(18) not null, | ||
refsetid varchar(18) not null, | ||
referencedcomponentid varchar(18) not null, | ||
acceptabilityid varchar(18) not null, | ||
PRIMARY KEY(id, effectivetime) | ||
); | ||
|
||
IF EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'curr_associationrefset_f') DROP TABLE curr_associationrefset_f; | ||
create table curr_associationrefset_f( | ||
id uniqueidentifier not null, | ||
effectivetime char(8) not null, | ||
active char(1) not null, | ||
moduleid varchar(18) not null, | ||
refsetid varchar(18) not null, | ||
referencedcomponentid varchar(18) not null, | ||
targetcomponentid varchar(18) not null, | ||
PRIMARY KEY(id, effectivetime) | ||
); | ||
|
||
IF EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'curr_attributevaluerefset_f') DROP TABLE curr_attributevaluerefset_f; | ||
create table curr_attributevaluerefset_f( | ||
id uniqueidentifier not null, | ||
effectivetime char(8) not null, | ||
active char(1) not null, | ||
moduleid varchar(18) not null, | ||
refsetid varchar(18) not null, | ||
referencedcomponentid varchar(18) not null, | ||
valueid varchar(18) not null, | ||
PRIMARY KEY(id, effectivetime) | ||
); | ||
|
||
IF EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'curr_simplerefset_f') DROP TABLE curr_simplerefset_f; | ||
create table curr_simplerefset_f( | ||
id uniqueidentifier not null, | ||
effectivetime char(8) not null, | ||
active char(1) not null, | ||
moduleid varchar(18) not null, | ||
refsetid varchar(18) not null, | ||
referencedcomponentid varchar(18) not null, | ||
PRIMARY KEY(id, effectivetime) | ||
); | ||
|
||
IF EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'curr_simplemaprefset_f') DROP TABLE curr_simplemaprefset_f; | ||
create table curr_simplemaprefset_f( | ||
id uniqueidentifier not null, | ||
effectivetime char(8) not null, | ||
active char(1) not null, | ||
moduleid varchar(18) not null, | ||
refsetid varchar(18) not null, | ||
referencedcomponentid varchar(18) not null, | ||
maptarget text not null, | ||
PRIMARY KEY(id, effectivetime) | ||
); | ||
|
||
IF EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'curr_extendedmaprefset_f') DROP TABLE curr_extendedmaprefset_f; | ||
create table curr_extendedmaprefset_f( | ||
id uniqueidentifier not null, | ||
effectivetime char(8) not null, | ||
active char(1) not null, | ||
moduleid varchar(18) not null, | ||
refsetid varchar(18) not null, | ||
referencedcomponentid varchar(18) not null, | ||
mapGroup smallint not null, | ||
mapPriority smallint not null, | ||
mapRule text, | ||
mapAdvice text, | ||
mapTarget text, | ||
correlationId varchar(18), | ||
mapCategoryId varchar(18), | ||
PRIMARY KEY(id, effectivetime) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
@echo off | ||
@echo --Importing SNOMED CT into MS SQL DB> import.sql | ||
@echo TRUNCATE TABLE curr_extendedmaprefset_f;>> import.sql | ||
@echo TRUNCATE TABLE curr_simplemaprefset_f;>> import.sql | ||
@echo TRUNCATE TABLE curr_attributevaluerefset_f;>> import.sql | ||
@echo TRUNCATE TABLE curr_simplerefset_f;>> import.sql | ||
@echo TRUNCATE TABLE curr_associationrefset_f;>> import.sql | ||
@echo TRUNCATE TABLE curr_langrefset_f;>> import.sql | ||
@echo TRUNCATE TABLE curr_stated_relationship_f;>> import.sql | ||
@echo TRUNCATE TABLE curr_relationship_f;>> import.sql | ||
@echo TRUNCATE TABLE curr_description_f;>> import.sql | ||
@echo TRUNCATE TABLE curr_concept_f;>> import.sql | ||
|
||
IF NOT EXIST Full\Terminology\sct2_Concept_Full_INT_* ( | ||
@echo Cannot find Full\Terminology\sct2_Concept_Full_INT_* | ||
EXIT /B 1 | ||
) | ||
for /r %%i in (Full\Terminology\sct2_Concept_Full_INT_*) do ( | ||
@echo BULK INSERT curr_concept_f FROM '%%i' WITH (FIRSTROW = 2, FIELDTERMINATOR = '\t', ROWTERMINATOR = '\n', TABLOCK^); >>import.sql | ||
) | ||
|
||
IF NOT EXIST Full\Terminology\sct2_Description_Full-en_INT_* ( | ||
@echo Cannot find Full\Terminology\sct2_Description_Full-en_INT_ | ||
EXIT /B 1 | ||
) | ||
for /r %%i in (Full\Terminology\sct2_Description_Full-en_INT_*) do ( | ||
@echo BULK INSERT curr_description_f FROM '%%i' WITH (FIRSTROW = 2, FIELDTERMINATOR = '\t', ROWTERMINATOR = '\n', TABLOCK^); >>import.sql | ||
) | ||
|
||
IF NOT EXIST Full\Terminology\sct2_TextDefinition_Full-en_INT_* ( | ||
@echo Cannot find Full\Terminology\sct2_TextDefinition_Full-en_INT_* | ||
EXIT /B 1 | ||
) | ||
for /r %%i in (Full\Terminology\sct2_TextDefinition_Full-en_INT_*) do ( | ||
@echo BULK INSERT curr_textdefinition_f FROM '%%i' WITH (FIRSTROW = 2, FIELDTERMINATOR = '\t', ROWTERMINATOR = '\n', TABLOCK^); >>import.sql | ||
) | ||
|
||
IF NOT EXIST Full\Terminology\sct2_Relationship_Full_INT_* ( | ||
@echo Cannot find Full\Terminology\sct2_Relationship_Full_INT_* | ||
EXIT /B 1 | ||
) | ||
for /r %%i in (Full\Terminology\sct2_Relationship_Full_INT_*) do ( | ||
@echo BULK INSERT curr_relationship_f FROM '%%i' WITH (FIRSTROW = 2, FIELDTERMINATOR = '\t', ROWTERMINATOR = '\n', TABLOCK^); >>import.sql | ||
) | ||
|
||
IF NOT EXIST Full\Terminology\sct2_StatedRelationship_Full_INT_* ( | ||
@echo Cannot find Full\Terminology\sct2_StatedRelationship_Full_INT_* | ||
EXIT /B 1 | ||
) | ||
for /r %%i in (Full\Terminology\sct2_StatedRelationship_Full_INT_*) do ( | ||
@echo BULK INSERT curr_stated_relationship_f FROM '%%i' WITH (FIRSTROW = 2, FIELDTERMINATOR = '\t', ROWTERMINATOR = '\n', TABLOCK^); >>import.sql | ||
) | ||
|
||
IF NOT EXIST Full\Refset\Language\der2_cRefset_LanguageFull-en_INT_* ( | ||
@echo Cannot find Full\Refset\Language\der2_cRefset_LanguageFull-en_INT_* | ||
EXIT /B 1 | ||
) | ||
for /r %%i in (Full\Refset\Language\der2_cRefset_LanguageFull-en_INT_*) do ( | ||
@echo BULK INSERT curr_langrefset_f FROM '%%i' WITH (FIRSTROW = 2, FIELDTERMINATOR = '\t', ROWTERMINATOR = '\n', TABLOCK^); >>import.sql | ||
) | ||
|
||
IF NOT EXIST Full\Refset\Content\der2_cRefset_AssociationReferenceFull_INT_* ( | ||
@echo Cannot find Full\Refset\Content\der2_cRefset_AssociationReferenceFull_INT_* | ||
EXIT /B 1 | ||
) | ||
for /r %%i in (Full\Refset\Content\der2_cRefset_AssociationReferenceFull_INT_*) do ( | ||
@echo BULK INSERT curr_associationrefset_f FROM '%%i' WITH (FIRSTROW = 2, FIELDTERMINATOR = '\t', ROWTERMINATOR = '\n', TABLOCK^); >>import.sql | ||
) | ||
|
||
IF NOT EXIST Full\Refset\Content\der2_Refset_SimpleFull_INT_* ( | ||
@echo Cannot find Full\Refset\Content\der2_Refset_SimpleFull_INT_* | ||
EXIT /B 1 | ||
) | ||
for /r %%i in (Full\Refset\Content\der2_Refset_SimpleFull_INT_*) do ( | ||
@echo BULK INSERT curr_simplerefset_f FROM '%%i' WITH (FIRSTROW = 2, FIELDTERMINATOR = '\t', ROWTERMINATOR = '\n', TABLOCK^); >>import.sql | ||
) | ||
|
||
IF NOT EXIST Full\Refset\Content\der2_cRefset_AttributeValueFull_INT_* ( | ||
@echo Cannot find Full\Refset\Content\der2_cRefset_AttributeValueFull_INT_* | ||
EXIT /B 1 | ||
) | ||
for /r %%i in (Full\Refset\Content\der2_cRefset_AttributeValueFull_INT_*) do ( | ||
@echo BULK INSERT curr_attributevaluerefset_f FROM '%%i' WITH (FIRSTROW = 2, FIELDTERMINATOR = '\t', ROWTERMINATOR = '\n', TABLOCK^); >>import.sql | ||
) | ||
|
||
IF NOT EXIST Full\Refset\Map\der2_sRefset_SimpleMapFull_INT_* ( | ||
@echo Cannot find Full\Refset\Map\der2_sRefset_SimpleMapFull_INT_* | ||
EXIT /B 1 | ||
) | ||
for /r %%i in (Full\Refset\Map\der2_sRefset_SimpleMapFull_INT_*) do ( | ||
@echo BULK INSERT curr_simplemaprefset_f FROM '%%i' WITH (FIRSTROW = 2, FIELDTERMINATOR = '\t', ROWTERMINATOR = '\n', TABLOCK^); >>import.sql | ||
) | ||
|
||
IF NOT EXIST Full\Refset\Map\der2_iisssccRefset_ExtendedMapFull_INT_* ( | ||
@echo Cannot find Full\Refset\Map\der2_iisssccRefset_ExtendedMapFull_INT_* | ||
EXIT /B 1 | ||
) | ||
for /r %%i in (Full\Refset\Map\der2_iisssccRefset_ExtendedMapFull_INT_*) do ( | ||
@echo BULK INSERT curr_extendedmaprefset_f FROM '%%i' WITH (FIRSTROW = 2, FIELDTERMINATOR = '\t', ROWTERMINATOR = '\n', TABLOCK^); >>import.sql | ||
) | ||
|