|
Hi, I am using a Cursor to parse filepaths. The parsing is working fine but the values aren't being written back to the table. There are no error messages. Can anyone suggest why?
(comments are locked)
|
|
First mistake: a CURSOR to update the table which can be a single UPDATE statement Second mistake: Used CURSOR with FOR UPDATE option but forgot to update the table. Use Robbin, Thanks for this. It worked. I took the code from a respected book and have triple-checked I followed the form. It doesn't have the UPDATE that you suggested so maybe the code wasn't intended to update the table. I thought it odd at the time but as a newbie I assumed the book was correct and would do an update. I really appreciate your help. The reason for the use of a cursor is that the code is trying to analyse strings that are not consistent. The path could just point to a genre folder, others to the sub-folders for artists and album names. It looks for '' chars. Some have two, others have three or four. I didn't feel the data was consistent enough for set-based parsing so each string is analysed in turn. Here are three examples; Directory of L:\Music\ANDINO The number and position of the slashes varies. If you can think of a way to do this set-based I would be delighted to hear about it as a newbie trying to learn the pro techniques. I really would like to thank you once again for your tremendous help. Cheers,
Jul 25 '12 at 07:25 PM
Karl
(comments are locked)
|
|
As @robbin says, it is very likely that a cursor is not going to be the most efficient way of making the updates that you want to. An UPDATE statement that applies to a set of rows in the table will be much quicker and cause less drain on server resources (CPU etc). If you want a hand working on that then feel free to start a new question but there are a lot of good resources on how to work effectively with SETS of data, which is how SQL Server is built to run. The construct of your code does seem to be missing a statement to actually update a table so adding that will certain make a difference. Currently the variables you are using get the values accurately, you just need to do something with them other than show them on screen with the As a side matter, I would seriously consider changing the table name. Using a hyphen (-) character in a table name is not a good idea. If you cant use
(comments are locked)
|


can you give us the details about the transform-albums table and a sample of its data please?