摘要:转自http://msdn.microsoft.com/zh-cn/library/ms175972(SQL.100).aspx指定临时命名的结果集,这些结果集称为公用表表达式 (CTE)。语法:[ WITH <common_table_expression> [ ,...n ] ]<common_table_expression>::=expression_name[ (...
阅读全文
摘要:转自http://sqlblog.com/blogs/peter_debetta/archive/2007/03/09/t-sql-convert-hex-string-to-varbinary.aspxSQL Server 2005中有一个没有文档说明的函数sys.fn_varbintohexstr,函数可把十六进制数转换为字符串表示的十六进制数(例如0x3a转换为'0x3a'),但是并没有函数...
阅读全文
摘要:使用RIGHT ( character_expression , integer_expression ) 返回字符串中从右边开始指定个数的字符。例如:SELECT RIGHT('FirstName', 5) AS 'First Name' --- tNameselect RIGHT ('000000' + cast ( 1 as varchar(6) ), 6)--- 000001select ...
阅读全文
摘要:SELECT * FROM sys.sysobjects WHERE xType = 'U' ORDER BY name ASCxType类型AF = Aggregate function (CLR)C = CHECK constraintD = DEFAULT (constraint or stand-alone)F = FOREIGN KEY constraintFN = SQL scalar...
阅读全文
摘要:触发器中使用Rollback Tran来取消要执行的操作,但是这样会显示错误提示信息:ALTER TRIGGER TestTriggerON TestTableFOR INSERT AS ROLLBACK TRANINSERT INTO TestTable VALUES ( 4 )Msg 3609, Level 16, State 1, Line 2The transaction ended in...
阅读全文