摘要: Random Sort OrderSummary: An example of how data can be sorted randomlyDECLARE@TESTTABLE(idintIDENTITY(1,1),valuevarchar(10)) INSERT@TESTVALUES('A') INSERT@TESTVALUES('B') INSERT@TESTVALUES('C') INSERT@TESTVALUES('D') INSERT@TESTVALUES('E') INSERT@TESTVALUES('F') SELECTvalue FROM@TEST ORDERBYNEWID() 阅读全文
posted @ 2011-01-24 13:45 Green.Lee 阅读(176) 评论(0) 推荐(0) 编辑
摘要: Change owner for all tablesSummary: An example of how to change the owner for all tablesDECLARE@oldOwnersysname,@newOwnersysname,@sqlvarchar(MAX) SELECT@oldOwner='',@newOwner='dbo', @sql=' IFEXISTS(SELECTNULLFROMINFORMATION_SCHEMA.TABLES WHERE QUOTENAME(TABLE_SCHEMA)+''.''+QUOTENAME(TABLE_NAME)=''?' 阅读全文
posted @ 2011-01-24 13:22 Green.Lee 阅读(179) 评论(0) 推荐(0) 编辑
摘要: Using the INSERTED table in SQL Server 2000Summary: An example trigger that shows how to get the values from an update statement and write them out to an audit tableTest data:--######STEP1-CREATINGTESTTABLESANDDATA##### --Createatesttable CREATETABLETABLE1(IDint,VALUEvarchar(50)) --Createatestauditt 阅读全文
posted @ 2011-01-24 13:20 Green.Lee 阅读(218) 评论(0) 推荐(0) 编辑
摘要: SQL Server 2005 Output MethodSummary: An example of how an inserted ID can be returned using the OUTPUT method in SQL Server 2005CREATETABLE#Test ( IDINTIDENTITY(1,1), ValueVARCHAR(10)NOTNULL, ) INSERTINTO#Test(Value) OUTPUTInserted.IDASID VALUES('Value1') 阅读全文
posted @ 2011-01-24 13:18 Green.Lee 阅读(285) 评论(0) 推荐(0) 编辑
摘要: Using CLR to access .NET functions in SQL ServerSummary: An example of how we can create a function in .NET and then use them in SQL Server.According to Microsoft, SQL Server 2005 significantly enhances the database programming model by hosting the Microsoft .NET Framework 2.0 Common Language Runtim 阅读全文
posted @ 2011-01-24 13:10 Green.Lee 阅读(837) 评论(0) 推荐(0) 编辑