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 |
mihir.mone
Starting Member
17 Posts |
Posted - 2010-10-20 : 22:15:31
|
I have 2 tables,COI, Company*** COI ***-------------------policyno codes------------------- 1 xxx,yyy 2 yyy*** Company ***---------------Code Name--------------- xxx SOS yyy CMCI want to write a query to retrieve which Companies are using the policies-- Result ------------------ policyno Name---------------- 1 SOS 1 CMC 2 CMCI tried with cross join, but I must admin I am not that good with SQL. Can anyone help me with this?Mihir. |
|
Sachin.Nand
2937 Posts |
Posted - 2010-10-21 : 01:20:27
|
First of all it is a BAD database design.Please never store values in columns in comma seperated format.As for your requirement write a table valued function to split the codes which will return codes which you can join with Company table on Code to get the desired result.PBUH |
 |
|
mihir.mone
Starting Member
17 Posts |
Posted - 2010-10-21 : 02:23:32
|
Thanks Sachin.I found some other way to generate this report. |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-10-21 : 02:36:17
|
quote: Originally posted by mihir.mone Thanks Sachin.I found some other way to generate this report.
Can you please let us you what did you use?PBUH |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
|
|
|
|