亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

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

SQL Script tips for MS SQL Server

瀏覽:114日期: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 數據庫
主站蜘蛛池模板: 制服丝袜中文字幕在线 | 免费观看黄视频 | 日本aaaa精品免费视频 | 伊人久久精品一区二区三区 | 五月婷婷综合基地 | 在线精品观看 | 国产欧美成人免费观看视频 | 日本中文不卡 | 成人免费a视频 | 狠狠色依依成人婷婷九月 | 欧美破处视频在线 | 久久99精品久久久久久秒播放器 | 91视频麻豆视频 | 国产高清在线免费视频 | 精品一区二区三区在线观看l | 色拍拍在线精品视频 | 美女白丝超短裙被输出动态图 | 婷婷综合视频 | 成人性色生活影片 | 久久国产美女免费观看精品 | 日韩在线 在线播放 | 三级福利视频 | 成人欧美一级毛片免费观看 | 欧美毛片一级的免费的 | 国产精品嫩模在线播放 | 国产综合成人久久大片91 | 亚洲综合视频网 | 一级一级一级一级毛片 | 男女晚上日日麻批视频不挡 | 永久免费aavv视频播放 | 亚洲福利在线观看 | 亚洲欧美日韩特级毛片 | 亚洲影音先锋看看 | 特级a毛片 | 国产精品久久国产三级国电话系列 | 亚洲成人精品 | 黄在线视频播放免费网站 | 欧美成人亚洲高清在线观看 | 国产成人精品亚洲午夜麻豆 | 亚洲综合视频网 | 91福利网址 |