July 10, 2013 at 6:01 am
Does there any possibility of fine tuning of my procedure to accommodate my requirement, I am stuck with the code.
Please help..
July 10, 2013 at 6:12 am
deepkt (7/10/2013)
Does there any possibility of fine tuning of my procedure to accommodate my requirement, I am stuck with the code.Please help..
We are helping. You are refusing to be helped. I don't know why you think that you are stuck with the code. But to fix your current solution, we would need to know the client code as well - and, no thanks, I don't want to see it.
Listen, we don't say these things out of thin air. I have tackled similar problems in the past the way you are trying to do, and I never got it work. There was always one more case. The only reasonable way is to send in all data in one go.
If you really want to update rows one by one, starting with negating all sorter values, and the update each row one by one to the new order. But that's a very ineffecient solution which will kill you sooner or later. So be a good boy and change the code to use a TVP, and learn something you can use in the future.
[font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]
July 10, 2013 at 7:32 am
Thanks for the reply..
I understood your point, If possible could you share logic using TVP .
Thanks. Sorry for keep on posting same query. But some how I have to fix it.
July 10, 2013 at 8:09 am
deepkt (7/10/2013)
I understood your point, If possible could you share logic using TVP .
I have already given it. When the user is done with the grid, populate the sorter column from the order in the grid, pass the TVP, please see http://www.sommarskog.se/arrays-in-sql-2008.html for examples, although assuming that you already have a DataTable, it is very simple. Just pass the DataTable as the value, and the type for the parameter is SqlDbType.Structured. (All assuming that you are using .Net.)
The stored procedure is just a straight update from the DataTable - or a MERGE statement, if you also want to permit the user to add and delete rows.
[font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]
Viewing 4 posts - 16 through 18 (of 18 total)
You must be logged in to reply to this topic. Login to reply