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

推荐订阅源

博客园 - Franky
N
Netflix TechBlog - Medium
Google Online Security Blog
Google Online Security Blog
月光博客
月光博客
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
V
V2EX
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
M
MIT News - Artificial intelligence
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
The Cloudflare Blog
Blog — PlanetScale
Blog — PlanetScale
F
Full Disclosure
G
Google Developers Blog
罗磊的独立博客
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
A
About on SuperTechFans
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队
GbyAI
GbyAI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
The Register - Security
The Register - Security
U
Unit 42
D
Docker
Martin Fowler
Martin Fowler
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
阮一峰的网络日志
阮一峰的网络日志
C
Cybersecurity and Infrastructure Security Agency CISA
博客园_首页
Google DeepMind News
Google DeepMind News

博客园 - flashicp

一个购物分享网站核心源码分析 ECSHOP读写分离配置与改造(转载) - flashicp 多年没有管理的技术博客了,即日起开始管理起技术博客 Apache里的 MPM 调优比较详细 c# WebBrowser网页操作-元素获取_事件操作 zend framework多模块多布局配置 c# office不同版本下中使用Excel - flashicp 目录下的文件 - 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();