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.
| Author |
Topic |
|
dineshrajan_it
Posting Yak Master
217 Posts |
Posted - 2010-05-06 : 05:53:55
|
| hi all,Query 1select genproduct_id as GENPRODUCT_ID, generic_product_Name as GENERIC_PRODUCT_NAME into #tmp from synCOREGENPRODUCT where generic_product_name = 'ampicillin 1 g injection'if not exists(select 1 from #tmp)Query2select DrugID as GENPRODUCT_ID,MedName as GENERIC_PRODUCT_NAME from USHR_GenericDrugs where MedName = 'ampicillin 1 g injection'elseselect * from #tmpThe question is when there is no record in 1st query then i have to go for second query and execute it else execute first query. is this good approach or any other stuff can be added. ThanksIam a slow walker but i never walk back |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-05-06 : 06:08:49
|
Rather than this:if not exists(select 1 from #tmp) You can use this:[code]IF @@ROWCOUNT = 0[code]------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee. |
 |
|
|
dineshrajan_it
Posting Yak Master
217 Posts |
Posted - 2010-05-06 : 06:17:48
|
quote: Originally posted by DBA in the making Rather than this:if not exists(select 1 from #tmp) You can use this:[code]IF @@ROWCOUNT = 0[code]------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee.
thanks.Iam a slow walker but i never walk back |
 |
|
|
|
|
|