I have the below table in my mssql.
itemNo itemDesc ComponentType Voltage 100001LF CAP CER 10n 25V 20% 0805 CAPACITOR NULL 100002LF CAP CER 10n 50V 20% 1206 CAPACITOR NULL 100008LF CAP CER 100n 25V 20% 0805 CAPACITOR NULL 100012LF CAP CERAM 1n 25V 20% 0805 CAPACITOR NULL 100013LF CAP CER 100n 25V 20% 0805 CAPACITOR NULLNow, how to determine the voltage from itemDesc and put it in to the Voltage ?
Note: The voltage can be determined like this: Search for the letter V , take all characters before you see a whitespace.
My initial attempt is this: [But, did not work :( ] UPDATE dbo.capacitor SET [Voltage] = CASE WHEN CHARINDEX('% ', ItemDesc) > 0 THEN SUBSTRING(itemDesc, CHARINDEX['V ', ItemDesc], CHARINDEX['V ',ItemDesc]+2) ELSE null END(I am using C# for the coding stuff. But, I wish this operation can be done with in SQL Server itself instead of using C# to take each record , process and put it back).