国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

SQL Script tips for MS SQL Server

瀏覽:117日期:2023-10-30 13:11:46

This posting will show you some script tips about MS SQL Server. 1. WaitforThe WAITFOR statement is specified with one of two clauses:(1) The DELAY keyword followed by an amount of time to pass before completing the WAITFOR statement. The time to wait before completing the WAITFOR statement can be up to 24 hours. For example,-- Wait for ten secondes before perforing a select statementWAITFOR DELAY '00:00:10'Select EmployeeID From Northwind.dbo.Employees

(2) The TIME keyword followed by a time to execute, which specifies completion of the WAITFOR statement.For example,-- Wait until 10:00 PM to perform a check of the pubs database to make sure that all pages are correctly allocalted and used.Use pubsBEGINWAITFOR TIME '22:00'DBCC CHECKALLOCEND

2. Enable SQL Debugging-- The SP_SDIDEBUG stored procedure is used by SQL Server for debugging Transact-SQL statementsUse masterGrant Execute on SP_SDIDEBUG to Username

3. Execute a dynamically built string(1) EXECUTE statementWith the EXECUTE statement, all parameter values must be converted to character or Unicode and made a part of Transact-SQL string. For example,DECLARE @IntVariable INTDECLARE @SQLString NVARCHAR(500)/* Build and execute a string with one parameter value. */SET @IntVariable = 35SET @SQLString = N'SELECT * FROM pubs.dbo.employee WHERE job_lvl = ' + CAST(@IntVariable AS NVARCHAR(10))EXEC(@SQLString)/* Build and execute a string with a second parameter value. */SET @IntVariable = 201SET @SQLString = N'SELECT * FROM pubs.dbo.employee WHERE job_lvl = ' + CAST(@IntVariable AS NVARCHAR(10))EXEC(@SQLString)

(2) SP_ExecuteSQLUsing sp_executesql is recommended over using the EXECUTE statement to execute a string. Not only does the support for parameter substitution make sp_executesql more versatile than EXECUTE, it also makes sp_executesql more efficient because it generates execution plans that are more likely to be reused by SQL Server.sp_executesql supports the setting of parameter values separately from the Transact-SQL string:

DECLARE @IntVariable INTDECLARE @SQLString NVARCHAR(500)DECLARE @ParmDefinition NVARCHAR(500)

/* Build the SQL string once. */SET @SQLString = N'SELECT * FROM pubs.dbo.employee WHERE job_lvl = @level'/* Specify the parameter format once. */SET @ParmDefinition = N'@level tinyint'

/* Execute the string with the first parameter value. */SET @IntVariable = 35EXECUTE sp_executesql @SQLString, @ParmDefinition, @level = @IntVariable/* Execute the same string with the second parameter value. */SET @IntVariable = 32EXECUTE sp_executesql @SQLString, @ParmDefinition, @level = @IntVariable

4. SP_HelpTextPrints the text of a rule, a default, or an unencrypted stored procedure, user-defined function, trigger, or view.-- This example displays the text of the employee_insupd trigger, which is in the pubs databaseUse PubsExec sp_helptext 'employee_insupd'

標簽: Sql Server 數據庫
主站蜘蛛池模板: 国产成人一区二区三区免费观看 | 国内免费自拍视频 | 久久亚洲国产高清 | 久久久久久网站 | 国内在线播放 | 精品久久久久久国产 | 中文字幕一级毛片 | 国产欧美一区二区三区在线看 | 97在线免费视频 | a级毛片免费高清毛片视频 a级毛片免费高清视频 | 日本国产免费一区不卡在线 | 久久免费资源 | 亚洲欧美在线不卡 | 成人公开免费视频 | 爱福利极品盛宴 | 亚洲三级视频在线观看 | 亚洲 欧美 日韩中文字幕一区二区 | 中文字幕日韩精品中文区 | 日本免费一区二区三区看片 | 国产乱弄视频在线观看 | 久久综合久久久 | 国产成人综合精品一区 | 美女视频在线观看黄 | 成年女人黄小视频 | 精品一区二区三区在线视频 | 色网站在线观看 | 色悠久久久久综合网伊人男男 | 美女黄色片免费 | 久久精品网站免费观看调教 | 亚洲久久久久 | 97视频免费播放观看在线视频 | 欧美成人免费观看国产 | 成人毛片免费观看视频大全 | 成人免费在线视频网 | 午夜影院黄色片 | 亚洲综合精品一区二区三区中文 | 亚洲狠狠综合久久 | 中文字幕精品一区二区绿巨人 | 亚洲风情第一页 | 一区国严二区亚洲三区 | 亚洲一区中文字幕在线 |