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

推荐订阅源

S
Secure Thoughts
罗磊的独立博客
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Last Week in AI
Last Week in AI
美团技术团队
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
月光博客
月光博客
L
LINUX DO - 最新话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
W
WeLiveSecurity
H
Heimdal Security Blog
Vercel News
Vercel News
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
博客园_首页
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
Intezer
K
Kaspersky official blog
M
MIT News - Artificial intelligence
J
Java Code Geeks
G
GRAHAM CLULEY
P
Palo Alto Networks Blog

博客园 - litsword

[转]IDENT_CURRENT、SCOPE_IDENTITY、@@IDENTITY 差異對照表 [转贴]TFS Power Tools–September 2010 Release SQL 中使用正则表达式过滤字母或数字 [转载]记不住ASP.NET页面生命周期的苦恼 Split Full Name as First and Last HTML 合并单元格示例 动态加载配置文件 [转载]实现PadLeft的SQL脚本 在Update 和 Delete语句中使用 Inner Join SQL游标遍历时的变量赋值 SQL Date Time format SCOPE_IDENTITY、IDENT_CURRENT 和 @@IDENTITY 的区别 Union合并数组(去掉重复的项目) Winform 版本信息 Sql语句 生日提醒 事件的定义 【原创】RSS开发心得小结 SQL数据类型nchar,char,varchar与nvarchar区别 JavaScript里面三个等号和两个等号的区别
Useful SQL script
litsword · 2012-02-08 · via 博客园 - litsword

-- 在数据库存储过程中查找文本字符(检索存储过程内容)

SELECT DISTINCT     o.name AS Object_Name,o.type_desc     FROM sys.sql_modules        m        
 INNER JOIN sys.objects  o ON m.object_id=o.object_id   
  WHERE m.definition Like '%key%'     ORDER BY 2,1

-- 强制写入自增长字段

SET IDENTITY_INSERT [KeyLookup] ON

  INSERT INTO table(KeyID, Value) Values(1, 123)

SET IDENTITY_INSERT [KeyLookup] OFF

--  查看表结构

EXEC sp_help table1

-- 查看存储过程

EXEC sp_helptext sp1

 
--  包含所有脚本在一个事务中,一旦发生错误回滚所有脚本
SET XACT_ABORT ON
GO

BEGIN TRAN

  -- start operation scripts

COMMIT TRAN
GO

-- 模糊查找表名或列名:

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME LIKE '%ABC%' OR COLUMN_NAME LIKE '%ABC%'

DBCC USEROPTIONS

如果修改了默认的隔离级别的话,这条命令会显示你设置的值,如果没有修改过(使用数据库默认的隔离级别)则不显示相关选项的值

QuoteName(@a) --> [@a]
STUFF('abcdeg', 2, 3, '123456')
For XML Path('') TYPE

查看数据库版本

SELECT @@VERSION

查看数据库兼容级别 (Compatibility Level)

SELECT compatibility_level FROM sys.databases WHERE name = 'db name'

80 - SQL Server 2000

90 - SQL Server 2005

100 - SQL Server 2008

110 - SQL Server 2012

修改数据库兼容级别 (Compatibility Level)

如果版本低于SQL2008:

exec sp_dbcmptlevel db1, 90

如果版本>= SQL2008:

ALTER DATABASE db1 SET compatibility_level = 90; Go;

1.通过使用 ALTER DATABASE SET SINGLE_USER,将数据库设置为单用户访问模式。

2.通过上述两种方法更改数据库的兼容级别。

3.通过使用 ALTER DATABASE SET MULTI_USER,将数据库设为多用户访问模式。