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

推荐订阅源

S
Secure Thoughts
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
Hugging Face - Blog
Hugging Face - Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
WordPress大学
WordPress大学
U
Unit 42
月光博客
月光博客
美团技术团队
S
Security Affairs
L
Lohrmann on Cybersecurity
Latest news
Latest news
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Recent Announcements
Recent Announcements
P
Palo Alto Networks Blog
The Last Watchdog
The Last Watchdog
T
Tor Project blog
Schneier on Security
Schneier on Security
Jina AI
Jina AI
MongoDB | Blog
MongoDB | Blog
Cloudbric
Cloudbric
B
Blog RSS Feed
Project Zero
Project Zero
Hacker News: Ask HN
Hacker News: Ask HN
Security Latest
Security Latest
C
Cybersecurity and Infrastructure Security Agency CISA
NISL@THU
NISL@THU
M
MIT News - Artificial intelligence
H
Help Net Security
Google DeepMind News
Google DeepMind News
L
LINUX DO - 热门话题
V
Visual Studio Blog
W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
Recent Commits to openclaw:main
Recent Commits to openclaw:main
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Threat Research - Cisco Blogs
Help Net Security
Help Net Security
F
Fortinet All Blogs
IT之家
IT之家
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
I
Intezer
D
DataBreaches.Net
C
Cyber Attacks, Cyber Crime and Cyber Security
Stack Overflow Blog
Stack Overflow Blog
SecWiki News
SecWiki News
Last Week in AI
Last Week in AI

博客园 - 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();