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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Intelligently update fields using another field !!

Author  Topic 

zeeshan13
Constraint Violating Yak Guru

347 Posts

Posted - 2007-07-05 : 12:11:30
Hi All,

I have a table called Product. It has the following important fields with thier respective datatypes.

ClientProductID (navarchar) (Its a primary key)
Name (nvarchar)
PackDescription (nvarchar)
Brand (nvarchar)

Each records hold the description for each product. There are 63319 records at this moment in the Product table, and it keep on increasing on a weekly basis. The PackDescription and Brand fields are NULL at the moment.
Following is an example of records that this table have. (Record in each field is sepearted by bracket)

[ClientProductID] [Name] [PackDescription] [Brand]
[10009] [TRICOFERO REGULAR 8OZ] [NULL] [NULL]
[10248765302] [YEMINA PASTA P SOPA CODO LISO 454GR] [NULL] [NULL]
[302] [YEMINA PASTA P 454 GR] [NULL] [NULL]
[7500074007552] [REFRESCO FLIRT PET 600 ML, COLA] [NULL] [NULL]
[10387081554] [SUSTITUTO DE CREMA LAUTREC 300 GRS] [NULL] [NULL]
[105001049] [LAGGS ICED TEA LIMON LATA 355ML NULL] [NULL]
[11848455570] [CONDIMENTO LA ANITA ACHIOTE PAST 110G] [NULL] [NULL]

Now using the Name I want to create a script that will update the PackDescription and Brand fields in the following way. (Record in each field is sepearted by bracket)

[ClientProductID] [Name] [PackDescription] [Brand]
[10009] [TRICOFERO REGULAR 8OZ] ['8] [OZ]
[10248765302] [YEMINA PASTA P SOPA CODO LISO 454GR] [454] [GR]
[302] [YEMINA PASTA P 454 GR] [454] [GR]
[7500074007552] [REFRESCO FLIRT PET 600 ML, COLA] [600] [ML]
[10387081554] [SUSTITUTO DE CREMA LAUTREC 300 GRS] [300] [GPRS]
[105001049] [LAGGS ICED TEA LIMON LATA 355ML] [355] [ML]
[11848455570] [CONDIMENTO LA ANITA ACHIOTE PAST 110G] [110] [G]

Now its a problem since I cannot manually update these fields for 63319 records, and the records keep on increasing on a weekly basis. Each record may have different PackDescription and Brand in the Name field, and it may have in a different format. I need to comeup with a smart script that will identify the PackDescription and Brand from the Name field, and then update the PackDescription and Brand fields accordingly so that I can run this script on a weekly basis.

Please let me know who can help me with this.

I am looking for a quick answere.

Thanks a million in advance...

Zee.


zeeshan13
Constraint Violating Yak Guru

347 Posts

Posted - 2007-07-05 : 15:28:18

Can anyone please help :( ?

Thanks a million in advance....
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-07-05 : 16:01:19
I doubt that we can provide any help, unless you can give a precise rule that is programmable in TSQL.

It is always easier to combine columns later into a single column than to split a column into parts.





CODO ERGO SUM
Go to Top of Page
   

- Advertisement -