Modify the field type and name in SQLServer

Source: Internet
Author: User
Modify the field type and name in SQLServer -- The following is the complete SQL Execution statement ifexists (select * fromsyscolumnswhere table name) and) -- determine whether this field exists beginALTERTABLE indicates the name of the ALTERCOLUMN field VARCHAR (64); -- change the type endGOifexis

Modify the field type and name in SQL Server-The following is the complete SQL Execution statement if exists (select * from syscolumns where id = object_id ('table name') and) -- determine whether the field has begin alter table, indicating that the alter column field name is VARCHAR (64); -- change the type of end GO if exis

Modify the field type and name in SQL Server

-- The following are complete SQL Execution statements:

If exists (select * from syscolumns where id = object_id ('table name') and) -- determine whether the field exists

Begin

Alter table indicates the alter column field name VARCHAR (64); -- change the type

End

GO

If exists (select * from syscolumns where id = object_id ('table name') and) -- determine whether the field exists

Begin

EXEC sp_rename 'indicates. Old Field name', 'new field name', 'column '; -- change field name sp_rename to data storage procedure

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.