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 |
oracle_corrgi
Yak Posting Veteran
98 Posts |
Posted - 2006-09-04 : 06:22:27
|
hican any one help withcase function with row count if row count is greater then 1 or >1 case1if row count is zero then case two ------this is my table and cloumn ---sample codeDECLARE @rc tinyint ,@var varchar(50)set @var = (SELECT emd.tpa_idfrom dbo.EMPLOYER_DIVISION AS ED,EMPLOYEE_MISC_DATA AS EMDwhere emd.tpa_id=ed.tpa_idandemd.empe_key=ed.division_key)SELECT ed.tpa_id, ed.division_key, emd.tpa_id, emd.empe_keyfrom dbo.EMPLOYER_DIVISION AS ED,EMPLOYEE_MISC_DATA AS EMDdatabase |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-04 : 06:26:30
|
quote: Originally posted by oracle_corrgi hican any one help withcase function with row count if row count is greater then 1 or >1 case1if row count is zero then case two ------this is my table and cloumn ---sample codeDECLARE @rc tinyint ,@var varchar(50)set @var = (SELECT emd.tpa_idfrom dbo.EMPLOYER_DIVISION AS ED,EMPLOYEE_MISC_DATA AS EMDwhere emd.tpa_id=ed.tpa_idandemd.empe_key=ed.division_key)SELECT ed.tpa_id, ed.division_key, emd.tpa_id, emd.empe_keyfrom dbo.EMPLOYER_DIVISION AS ED,EMPLOYEE_MISC_DATA AS EMDdatabase
IF EXISTS (SELECT * FROM dbo.EMPLOYER_DIVISION AS ED inner join EMPLOYEE_MISC_DATA AS EMD on emd.tpa_id = ed.tpa_id and emd.empe_key = ed.division_key) SELECT emd.tpa_id from dbo.EMPLOYER_DIVISION AS ED inner join EMPLOYEE_MISC_DATA AS EMD on emd.tpa_id = ed.tpa_id and emd.empe_key = ed.division_keyELSE SELECT ed.tpa_id, ed.division_key, emd.tpa_id, emd.empe_key from dbo.EMPLOYER_DIVISION AS ED cross join EMPLOYEE_MISC_DATA AS EMD Peter LarssonHelsingborg, Sweden |
|
|
|
|
|
|
|