SQL Server
  Home arrow SQL Server arrow Execute SQL on Multiple Tables/Columns - N...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
SQL SERVER

Execute SQL on Multiple Tables/Columns - New Feature in SQL Server 2000
By: Raghavendra Narayana
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 46
    2003-09-25

    Table of Contents:
  • Execute SQL on Multiple Tables/Columns - New Feature in SQL Server 2000
  • Script
  • Parameters
  • Examples
  • Expansion
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Execute SQL on Multiple Tables/Columns - New Feature in SQL Server 2000


    (Page 1 of 6 )

    In this latest article, Raghavendra introduces us to a feature available to us in SQL Server, allowing us to execute SQL statements on multiple tables and columns.

    The base idea of this article is to leverage the running of SQL Statements, Stored Procedures, User Defined Functions or a set of SQL Statements on every/required tables and on every/required columns in the Database. 

    You may have had a requirement in which you needed to add/edit/delete/search data in column(s) on more than one table using a single SQL statement; perhaps you ended up writing a procedure/function for achieving just that.  Now you can be equipped with the SP_execSQLonDB stored procedure that runs the SQL Statement(s)/Procedure/Function on every finding of required tables/columns in the Database.

    Algorithm

    • Accept Table name filter, Column name filter, SQL, Include_NTI (i.e. whether to include Ntext, Text, Image data types during stored procedure execution, usually these data types give errors during data comparison) parameters.
    • Check whether to include TEXT, NTEXT and IMAGE data types.  Check whether to include Table and column filters.
    • Fetch a Result Set that contains the Table and Column names with associated owner name by querying on SQL SERVER System Tables based on the input parameters.
    • Loop through the Result Set
      • Execute the supplied SQL for each row in the result set

    More SQL Server Articles
    More By Raghavendra Narayana


     

    SQL SERVER ARTICLES

    - Executing SQL Server Stored Procedure from P...
    - How to Search for Date and Time Values Using...
    - Replication: SQL Server 2000 - Part 2
    - Replication: SQL Server 2000 - Part 1
    - SQL Sever: Storing Code in Binary or Text Fi...
    - Execute SQL on Multiple Tables/Columns - New...
    - How to Connect to a SQL Server from Visual F...
    - SQL Server Hardware Tuning and Performance M...
    - Primary Key on Multiple Tables – New RDBMS C...
    - Migrating from Sybase to SQL Server
    - What's Best for DBAs? GUI or T-SQL Comma...
    - How to Perform a SQL Server Performance Audit
    - An Introduction To The Bulk Copy Utility
    - SQL Server Stored Procedures 101
    - Building Your First SQL Server 2000 Database







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek