tsql - T-SQL update with switch-case statement -


I want to implement this pseudo in T-SQL

  UPDATE processing SET [ Path] = case ([path]. Substrings ([path]. Let index ('.'))) WHEN '.jpg' THEN '/image.jpg' WHEN '.png' THEN '/image.jpg' WHEN ' . AVG 'THEN' / Video.jpg 'WHEN' .mkv 'THEN' /video.jpg '  

For this I use this solution

  UPDATE RESOURCES SET [path] = CASE (SUBSTRING ([path], LAN ([path]) - Cherrindx ('.', Reverse ([path])) + 1, 3) WHEN '.jpg' THEN '/ image .jpg 'WHEN' .png 'THEN' /image.jpg 'WHEN' .avi 'THEN' /video.jpg 'WHEN' .mkv 'THEN' /video.jpg 'END   

But it is

Try it instead:

  SUBSTRING (path, LAN (path) - chordix ('.', Reverse (path)) + 1, LAN (path)   

( LEN ( Path) as the length of reading; OK If it allows for ND and N-character extensions of E string)

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -