Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Insert values

Author  Topic 

jgeorge
Starting Member

6 Posts

Posted - 2015-03-25 : 17:33:22
I have more than 720000 lines when I execute the following sql, There are only 2200 of the 'name' but each name associated with multiple code/levelcode etc.

Is there a way that I can insert one code/LevelCode/HL7Code to each 2000 names ?

---------------------------------------------------------------------
select
distinct
ocmi.name [name] , cit.active [taskactive],
Code,LevelCode,HL7Code
FROM cv3ordercatalogmasteritem ocmi
left join cv3catalogitemtask cit
on ocmi.guid=cit.ordercatalogmasteritemguid
LEFT JOIN CV3CatalogTaskLocationXRef tasklocxref
on cit.guid=tasklocxref.CatalogItemTaskGUID
join cv3location l
on l.guid=tasklocxref.LocationGroupGUID
WHERE ocmi.active=1
and ocmi.name not like 'zz%'
and ocmi.name not like 'qq%'
and ocmi.name <> 'refill'
and ocmi.name not like 'qa%'
and ocmi.name not like 'Saline Lock%'

/*
select ocmi.name

from cv3ordercatalogmasteritem ocmi

left JOIN

CV3OrganizationalUnit ou

ON ocmi.orgunitguid = ou.guid

where ou.name = 'Pharmacy'
and ou.active=1
and ocmi.name not like 'zz%'
and ocmi.name not like 'qq%'
and ocmi.name <> 'SK RX UOMTEST'
and ocmi.name <> 'SKStylenol'
and ocmi.name <> 'refill'
and ocmi.name not like 'qa%'
and ocmi.active=1*/
order by ocmi.Name

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2015-03-25 : 20:19:18
Show us some sample data and expected output.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

jgeorge
Starting Member

6 Posts

Posted - 2015-03-26 : 10:47:08
Name Taskactive Code Level Code HL7Code
bacitracin sterile powder 1 PLC|Emergency |PLC ED |Main WR Main WR PLC |PLC ED |MAIN WR |
bacitracin sterile powder 1 SHC|.Inpatient|SHCICUB| SHCICUB SHC|SHCICUB |

|
For each name there are 650 plus rows and there are 2200 plus names. I would like to insert one distinct Code,Levelcode,HL7Code for each of the 2200 plus names.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2015-03-26 : 12:56:34
We need to see sample data AND expected output.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

jgeorge
Starting Member

6 Posts

Posted - 2015-03-26 : 14:46:39
While executing the query , I am getting the output as mentioned, It is the sample data.
This is the select query and I need to insert some more values to these tables, as mentioned, with a different code/level Code/HL7 Code
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2015-03-26 : 14:47:09
Here is how to post the needed information: http://www.sqlservercentral.com/articles/Best+Practices/61537/

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2015-03-26 : 14:47:53
And if you aren't a user of SQL Server Central, then signup so you can read the article.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -