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

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

SQL Script tips for MS SQL Server

瀏覽:139日期: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 數據庫
主站蜘蛛池模板: 韩国免又爽又刺激激情视频 | 我要看三级毛片 | 波多野结衣视频免费观看 | 亚洲免费网站在线观看 | 欧美视频成人 | 久久中文亚洲国产 | 三级亚洲 | 成人国产精品视频频 | 未满14周岁啪啪网站 | 日韩一区二区三区在线播放 | 成年人免费在线视频观看 | 成人亚洲欧美日韩中文字幕 | 成年人看的黄色片 | 欧美成人精品欧美一级乱黄 | 亚洲天天在线 | 国产日本韩国不卡在线视频 | 一道精品视频一区二区三区图片 | 最新国产精品亚洲二区 | 国产精品hd在线播放 | 波多野结衣在线观看免费区 | 五月天激激婷婷大综合蜜芽 | 欧美超高清xoxoxoxo | 嫩小性性性xxxxbbbb | 人成在线免费视频 | 毛片网站在线播放 | 品色堂永久免费 | 欧美顶级毛片在线播放小说 | 精品国产香港三级 | 澳门毛片在线播放 | 99视频在线播放 | 精品一区二区久久 | 久久精品.com | 国产91香蕉视频 | 国内在线播放 | 免费人成黄页网站在线观看国产 | 黄色片日本人 | 欧美一级一级片 | 免费一级特黄 欧美大片 | 美国美女一级毛片免费全 | 男人天堂手机在线 | 精品久久久久国产 |