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

推荐订阅源

I
Intezer
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
AWS News Blog
AWS News Blog
G
GRAHAM CLULEY
P
Privacy & Cybersecurity Law Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
N
News | PayPal Newsroom
T
Tenable Blog
Spread Privacy
Spread Privacy
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Secure Thoughts
P
Privacy International News Feed
IT之家
IT之家
Project Zero
Project Zero
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
博客园_首页
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
量子位
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
Martin Fowler
Martin Fowler
NISL@THU
NISL@THU
I
InfoQ
D
DataBreaches.Net
有赞技术团队
有赞技术团队
K
Kaspersky official blog
Security Latest
Security Latest
The Register - Security
The Register - Security
Hugging Face - Blog
Hugging Face - Blog
S
Security @ Cisco Blogs
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
AI
AI
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
N
News and Events Feed by Topic

博客园 - 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,将数据库设为多用户访问模式。