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 |
|
rds207
Posting Yak Master
198 Posts |
Posted - 2010-04-13 : 14:32:32
|
| HiCould any body please help me writing a stored procedure to update the column Resource, Resource_poolI have 2 table , for eg , as look up tables by which the column resource and resorce pool has to be updated .Sample Data : Here are some of the examples of distinct resource and resource pool i have each with a unique code.Look up Table 1: Resource_POOLRESOURCE_POOL_NAME RESOURCE_POOL_CODEPod1 1Pod2 2FixStatus 3 CRMBuilds 4 Look Up TABLE 2 : RESOURCERESOURCE_NAME Resource_CODESTRUT 1BTRPOD103 2BTRPOD204 3QCTCRMBLD04 4I have a source table , which has columns HOST_NAME AND RESOURCE NAME which are combinations of resource_pool and resource_namesHere is the source table output with HOST_NAME AND RESOURCE_NAME columnsHOST_NAME RESOURCE_NAMEBTRPOD101 Pod1BTRPOD204 Pod2QCTCRMBLD04 CRMBuildsQCTCRMBLD04 CRMBuildsNULL STRUTFIXSTATUS FIXSTATUSBasically we treat HOST_NAME as Resource_nameand Resource_name AS Resource_Pool_NameSo , for eg , if we take STRUT from the above output , STRUT is an a resource ( Please look into the look up table 2), but in the above output it is entered in the column resource_name which is treated as a resource_pool.Another example is FIXSTATUS which is a resource pool(Please look into the Look up table 1) but it is both in host_name and resource_name , So i need to create 2 new columns which distinguishes between resource and resource_pool_names.Either i need to write a stored procedure or a query or a program which actually separates resources and resource_pool_namesHere is the expected output for the above data:HOST_NAME RESOURCE_NAME RESOURCE RESOURCE_POOL_NAMEBTRPOD101 Pod1 BTRPOD101 Pod1BTRPOD204 Pod2 BTRPOD204 Pod2 QCTCRMBLD04 CRMBuilds QCTCRMBLD04 CRMBuildsQCTCRMBLD04 CRMBuilds QCTCRMBLD04 CRMBuildsNULL STRUT STRUT nullFIXSTATUS FIXSTATUS null FIXSTATUSPlease Help.... |
|
|
rds207
Posting Yak Master
198 Posts |
Posted - 2010-04-13 : 17:56:59
|
| Please let me know if the question is not clear ..I have tried writing some update queries , but looks like update does not work as its just updating either of the columns.Please Suggest what is the best way to achieve this... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-14 : 00:08:52
|
| your rules are not clear. What was the reason why FIXSTATUS was repeated for HOST_NAME & RESOURCE_NAME? Also how come BTRPOD204 & Pod2 came in same row (they've different ids). how are tables related then?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|