简体   繁体   中英

Swap two records excluding few columns using stored procedure in SQL Server 2000/2005

How to create a stored procedure (for SQL Server 2000 / 2005) to swap 2 records excluding a few columns, it has to get "table name", "record id (2 id)" and "column to exclude" as a parameter. Here columns are dynamic as we get 'table' as a parameter and number of columns may be more than 50.

Here I believe, "update [table name] set [field] = [value] ......"

Type statements will be very lengthy as the number of columns will be more than 50 and it is a variant.

Is there any simple way to swap records in SQL Server 2000/2005?

Check this answer by Tom H. to similar question.

Also this solution posted on SQLServerCentral may be helpful to you (the site requires registration but it is free)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM