---
title: "在指定的位置添加列"
author: "devilhand"
date: "2011-12-27T13:42:35Z"
tags: []
categories: ["数据库"]
slug: "untitled"
draft: false
lastmod: "2011-12-27T13:42:35Z"
id: 1327715
url: "https://devilhand.iteye.com/blog/1327715"
---

```
--允许系统标更新
exec sp_configure 'allow updates','1'
go
reconfigure with override
go

----添加列
ALTER TABLE dbo.GoodsPrinter ADD GoodsStallId NVARCHAR(100)

--把第一列之后的列往后移1（colid从1开始）
update syscolumns set colid=colid+1 where colid>=2 and id = object_id('GoodsPrinter')

--更新列顺序
update syscolumns set colid=2 where name='GoodsStallId' and id=object_id('GoodsPrinter')

--禁用系统标更新
exec sp_configure 'allow updates','0'
go
reconfigure with override
GO
```