惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

K
Kaspersky official blog
Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
博客园_首页
Engineering at Meta
Engineering at Meta
The Cloudflare Blog
MongoDB | Blog
MongoDB | Blog
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
雷峰网
雷峰网
D
Docker
博客园 - 司徒正美
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
U
Unit 42
J
Java Code Geeks
A
About on SuperTechFans
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security Affairs
I
Intezer
Cisco Talos Blog
Cisco Talos Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
B
Blog RSS Feed
P
Privacy & Cybersecurity Law Blog
T
Tenable Blog
T
Threatpost
H
Hacker News: Front Page
G
Google Developers Blog
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
L
Lohrmann on Cybersecurity
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
A
Arctic Wolf
S
Secure Thoughts
GbyAI
GbyAI
NISL@THU
NISL@THU
S
Security @ Cisco Blogs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Webroot Blog
Webroot Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
O
OpenAI News
Spread Privacy
Spread Privacy
Application and Cybersecurity Blog
Application and Cybersecurity Blog

博客园 - 琼

服务器 'server_1' 上的 MSDTC 不可用 - 琼 用javascript操作word文档 - 琼 - 博客园 Asp.Net中用javascript实现弹出窗口永远居中 - 琼 - 博客园 在sql server 2005数据库中更改数据架构 实现跟踪javascript代码进行调试 转摘--MS SQL Server 2000 数据库使用备份还原造成的孤立用户和对象名‘xxx’无效的错误的解决办法 转摘--具体影响Oracle系统性能的初始化参数 转摘--深入解读ADO.NET2.0的十大最新特性 实现关闭弹出页面后刷新父页 转摘——仿网易126网络硬盘上传 - 琼 - 博客园 javascript中获取文件后缀名 用Javascript隐藏超级链接的真实地址 UltraWebGrid模板列及行的相关操作(转) JavaScript实现DataGrid中的CheckBox全选与否 实现弹出窗口的大小 解决"当前命令发生了严重错误。应放弃任何可能产生的结果。"的问题 设置页面文字大小及颜色 图片幻灯片显示 Windows 2000 CMD命令大全
转摘_修改表结构,让表中的字段按英文字母的顺序重新排列
· 2007-12-07 · via 博客园 - 琼

转摘CSDN

比如:
数据表中有字段,原先排列是这样:
B   A   D   C   E   F

现在要求用SQL修改表结构让它重新排列,按英文字母排,这样:
A   B   C   D   E   F  

--遍历表
  go
  sp_configure 
'allow updates',1 
  
go 
  
RECONFIGURE   WITH   OVERRIDE 
  
go
  
declare @SQL varchar(4000)
  
declare @TableName varchar(30)
  
declare sTableName Cursor for select [name] from sysobjects where xtype='u' and name<>'dtproperties'
  
Open sTableName
  
fetch next from sTableName into @TableName
  
while @@fetch_status=0
  
begin
    
--更新 
    set @SQL='update syscolumns set colid=(select count(*) from syscolumns a where a.name<=syscolumns.name and a.id=syscolumns.id),colorder=(select count(*) from syscolumns a where a.name<=syscolumns.name and a.id=syscolumns.id) where id=object_id('''+@TableName+''')' 
    
print(@SQL)
    
exec(@SQL)
    
fetch next from sTableName into @TableName
  
end

  
close sTableName    
  
deallocate sTableName
  
  
go
  sp_configure 
'allow updates',0 
  
go 
  
RECONFIGURE   WITH   OVERRIDE