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

推荐订阅源

博客园 - 司徒正美
T
The Blog of Author Tim Ferriss
雷峰网
雷峰网
S
Secure Thoughts
GbyAI
GbyAI
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed
G
GRAHAM CLULEY
MongoDB | Blog
MongoDB | Blog
WordPress大学
WordPress大学
M
MIT News - Artificial intelligence
Martin Fowler
Martin Fowler
C
Cyber Attacks, Cyber Crime and Cyber Security
I
Intezer
A
About on SuperTechFans
Hugging Face - Blog
Hugging Face - Blog
T
Threatpost
S
Securelist
T
Tenable Blog
博客园_首页
P
Privacy International News Feed
Cisco Talos Blog
Cisco Talos Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
C
CXSECURITY Database RSS Feed - CXSecurity.com
小众软件
小众软件
美团技术团队
Project Zero
Project Zero
The Cloudflare Blog
L
Lohrmann on Cybersecurity
The Register - Security
The Register - Security
B
Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LINUX DO - 热门话题
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
有赞技术团队
有赞技术团队
IT之家
IT之家
A
Arctic Wolf
Scott Helme
Scott Helme
Latest news
Latest news
T
Tailwind CSS Blog
Jina AI
Jina AI
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
Cyberwarzone
Cyberwarzone
宝玉的分享
宝玉的分享
The Hacker News
The Hacker News
S
Schneier on Security
Y
Y Combinator Blog

博客园 - flashicp

一个购物分享网站核心源码分析 ECSHOP读写分离配置与改造(转载) - flashicp 多年没有管理的技术博客了,即日起开始管理起技术博客 Apache里的 MPM 调优比较详细 c# WebBrowser网页操作-元素获取_事件操作 zend framework多模块多布局配置 c# office不同版本下中使用Excel 目录下的文件 - flashicp - 博客园 中秋 国庆 最近在忙项目,好久不来 转 :如何提高自己的编程水平 衣物去污指南 转 洗衣小窍门集锦 牙膏的妙用 转 家居小窍门 (二) 转 家居小窍门 (一) 转 --有些事情需要注意 WinForm的App.config 保存我的操作日志
关于sql server表名 和字段的一点操作
flashicp · 2007-08-07 · via 博客园 - flashicp

1、
数据库中表名查询
select name from sysobjects where type = 'U'
select name from sysobjects where type = 'U'  and name!='dtproperties'

查询数据库中用户表(type='U'),表名中不含_OPLOGS字样,和_LOGS字样,以及表名中必须包含下划线(_).
/*  use  **DB
select name from  sysobjects   where ( type = 'U'  and  name!='dtproperties' and  (not name like  '%_OPLOGS%') and  (not name like  '%_LOGS%') ) and  name like '%[_]%'
*/
2、
修改表字段,如:向SHUXUE表 添加AA字段。
/*
ALTER table  SHUXUE  add AA varchar(40) null
*/
3、
表中是否存在某字段的查询语句,如果不存在返回-1.
StringBuilder sqlStr=new StringBuilder();
     
    sqlStr.Append("if not exists   (select   *   from   syscolumns   where   id=object_id('");
    sqlStr.Append(tableName);
    sqlStr.Append( "')   and   name='");
    sqlStr.Append(tableName).Append("_AA')");
    sqlStr.Append(" select -1 as mycount ");

    return sqlStr.ToString();
4、
// if   exists   (select   *   from   syscolumns   where   id=object_id('SHENGWU')   and   name='SHENGWU_P') 
// print   'exists'

5、
为表添加字段。可以侦测表中有没有这字段。
如果没有,添加该字段。

转-- -用存储过程来实现 修改表格字段

create   procedure funcaddcolumn
@tablename  varchar(128),  -- 表名
@columnname varchar(128),---列名
@columntype varchar(128) -- 列定义

as
set @tablename = ltrim(rtrim(@tablename))
set @columnname = ltrim(rtrim(@columnname))
set @columntype = ltrim(rtrim(@columntype))

declare @string varchar(8000)

if not exists( select * from syscolumns where id=object_id(@tablename) and name = @columnname )
begin
select  @string =  alter  table + @tablename + add [ + ltrim(rtrim(@columnname)) + ]  + @columntype + null
print @string
execute(@string)
end
go

6、
GUID(Global unique identifier)全局唯一标识符,它是由网卡上的标识数字(每个网卡都有唯一的标识号)以及 CPU 时钟的唯一数字生成的的一个 16 字节的二进制值。

GUID 的格式为“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,其中每个 x 是 0-9 或 a-f 范围内的一个十六进制的数字。例如:6F9619FF-8B86-D011-B42D-00C04FC964FF 即为有效的 GUID 值。
世界上的任何两台计算机都不会生成重复的 GUID 值。GUID 主要用于在拥有多个节点、多台计算机的网络或系统中,分配必须具有唯一性的标识符。在 Windows 平台上,GUID 应用非常广泛:注册表、类及接口标识、数据库、甚至自动生成的机器名、目录名等

在这次开发时,我使用了:
StringBuilder sqlStr=new StringBuilder();

    sqlStr.Append( "update ").Append(tableName);
    sqlStr.Append(" set ").Append(tableName).Append("_AA=NewID()");

    return sqlStr.ToString();