dev-exchange.com logo

dev-exchange.com latest topics RSS feed

Book mark: Add http://www.dev-exchange.com/cms_view_article.php?aid=13&start=0 to your delicious account Add http://www.dev-exchange.com/cms_view_article.php?aid=13&start=0 to your digg account Add http://www.dev-exchange.com/cms_view_article.php?aid=13&start=0 to your blinklist account Add http://www.dev-exchange.com/cms_view_article.php?aid=13&start=0 to your reddit account Add http://www.dev-exchange.com/cms_view_article.php?aid=13&start=0 to Dzone Add http://www.dev-exchange.com/cms_view_article.php?aid=13&start=0 to your furl account Add http://www.dev-exchange.com/cms_view_article.php?aid=13&start=0 to your stumble account Add http://www.dev-exchange.com/cms_view_article.php?aid=13&start=0 to your Yahoo myweb account
Article Menu
Google
ColdFusion MX
PHP
ASP
ASP.Net
XML-XSLT
JavaScript
SQL Server
AJAX
 


 
Article
fooclass
Junior Member
Junior Member

Articles: 4 Comments: 1
 Posted: Fri Jul 06, 2007 3:46 pm

Some of the applications may need to update the database procedure with bulk records at one go.
Instead of doing a loop calling the stored procedure, an array value can be passed to the stored procedure and update the database. I use this procedure to insert or update database values.


Code:
Create procedure usp_updaterecords (@ArrayInput varchar(8000)) as

BEGIN
    SET NOCOUNT ON

    DECLARE @Row varchar(10), @Position int

    SET @ArrayInput = LTRIM(RTRIM(@ArrayInput))+ ','
    SET @Position = CHARINDEX(',', @ArrayInput, 1)

    IF REPLACE(@ArrayInput, ',', '') <> ''
    BEGIN
      WHILE @Position > 0
      BEGIN
         SET @Row = LTRIM(RTRIM(LEFT(@ArrayInput, @Position - 1)))
         IF @Row <> ''
         BEGIN
               -- add your insert or update statement here
            
           END
         SET @ArrayInput = RIGHT(@ArrayInput, LEN(@ArrayInput) - @Position)
         SET @Position = CHARINDEX(',', @ArrayInput, 1)
      END
    END   
END

GO



Input value should be separated with ‘,’ comma. This procedure splits the values and assigns it to @Row variable.
If you have a situation like this, I may be able to help you. Post your comments or suggestions here.
Rating: 5.00/5.00 [1]

Comments
No comments were made for this article
 

All times are GMT

Jump to:  
You cannot post articles in this chapter
You cannot edit your articles in this chapter
You cannot delete your articles in this chapter
You cannot rate articles in this chapter

You cannot post comments in this chapter
You cannot edit your comments in this chapter
You cannot delete your comments in this chapter
You cannot rate comments in this chapter


© 2008 dev-exchange.com
Powered by phpBB. Theme DEVPPL.