Traverse the database to delete the row data for the table that contains the specified columns-

Source: Internet
Author: User


IF object_id ('dbo.spdeleterowdate_in_db') is not NULL DROP PROCEDURE dbo.spdeleterowdate_in_db gocreate proc spdeleterowdate_in_db (@compidint--Company ID) Asdeclare @tableName varchar ( -) DECLARE my_cursor Cursor--defines a cursor for (Selectobject_name (ID) fromsyscolumnswhereIdinch(SelectId fromsysobjectswhereType='U') and name='Compid') --isolate the desired set into the cursor open my_cursor;--Open cursor fetch NEXT from my_cursor to @tableName;--reads the first row of data (puts the table name into the @tablename variable) while @ @FETCH_STATUS=0BEGIN declare @sql nvarchar ( +) Set@sql ='Delete from'[Email protected]+'where compid='+convert (varchar ( -), @compid) print @sql exec (@sql) FETCH NEXT from My_cursor to @tableName; --read the next line of data endclose My_cursor;--close the cursor deallocate my_cursor;--release cursor Go--exec spdeleterowdate_in_db1

Traverse the database to delete the row data for the table that contains the specified columns-

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.