色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

SQL Script tips for MS SQL Server

瀏覽:131日期: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'

主站蜘蛛池模板: 国内自拍小视频 | 亚洲黄色小视频 | a级毛片毛片免费观看永久 a级毛片毛片免费很很综合 | 欧美日韩一区二区三区视频播 | 欧美日韩在线第一页 | 免费看一级欧美毛片视频 | 成人午夜看片在线观看 | 国产毛片一级国语版 | 一本久道综合久久精品 | 欧美在线一区二区三区不卡 | 欧美日一区| 国产精品91在线播放 | 成人影院一区二区三区 | a毛片在线播放 | a级毛片毛片免费观看永久 a级毛片毛片免费很很综合 | 在线观看一区 | 中文字幕乱码无线码在线 | 国产a级特黄的片子视频 | 高清大学生毛片一级 | 韩国福利影视一区二区三区 | 亚洲免费三级 | 在线观看国产精品入口 | 亚洲欧美一区二区三区在线播放 | 成人免费的性色视频 | 九一国产精品视频 | 亚洲 欧美 精品 中文第三 | 91精品免费久久久久久久久 | 久久99国产乱子伦精品免费 | 国产97公开成人免费视频 | 国内免费视频成人精品 | 91久久精品国产91久久性色也 | 精品色视频 | 国产精品久久福利网站 | 国产真实乱子伦xxxxchina | 国产男女爽爽爽爽爽视频 | 国产欧美日韩不卡在线播放在线 | 日韩一页| 国产精品高清在线 | 97国产精品视频观看一 | 欧美特级特黄a大片免费 | 正在播放国产精品放孕妇 |