SQLTeam.com | Weblogs | Forums

Inserting values


#1

I have 3 tables which are connected like this.

Cv3ordercatalogmasteritem 1
CV3CatalogClassTypeValue 2
CV3ClassType 3.

2.CatalogMasterGUID=1.GUID
3.GUID=2.ClasstypeGUID

How can I insert values into TABLES 2 AND 3 which satisfies the above condition ?


#2

Your description is not quite clear - I find it hard to understand what you are trying to do.

-- insert everything from Cv3ordercatalogmasteritem into
-- CV3CatalogClassTypeValue
INSERT INTO CV3CatalogClassTypeValue 
	([GUID], CatalogMasterGUID)
SELECT
	NEWID(), [GUID]
FROM
	Cv3ordercatalogmasteritem;


-- insert everything from CV3CatalogClassTypeValue into
-- CV3ClassType
INSERT INTO CV3ClassType
	([GUID], ClasstypeGUID)
SELECT
	NEWID(), [GUID]
FROM
	CV3CatalogClassTypeValue;

#3

Thank you,

finally, once I insert thru a load process (takes more than an hour) I check the values thru this sql. if this helps.

select distinct
ocmi.name,
ct.code,
ctv.value
from
cv3ordercatalogmasteritem ocmi
join CV3CatalogClassTypeValue ctv on ctv.CatalogMasterGUID = ocmi.guid
join CV3ClassType ct on ct.guid = ctv.ClassTypeGUID
where
ocmi.expirydate is null
and ct.code like 'Acute Kidney Injury - AKI'
and value='nephrotoxicity'
and ctv.active = 1
and ct.active = 1
order by
ocmi.name