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

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

SQL Script tips for MS SQL Server

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

主站蜘蛛池模板: 韩国一级黄色大片 | 国产成人丝袜视频在线视频 | 欧美大片无尺码在线观看 | 欧美操操操 | 精品视频一区二区 | 欧美成人高清 | 精品成人在线观看 | 亚洲最大情网站在线观看 | 日本一级特黄大一片免 | 国产精品亚洲欧美日韩一区在线 | 欧美大片欧美毛片大片 | 欧美色黄毛片 | 怡红院成人网 | 自拍在线视频 | 成人全黄三级视频在线观看 | 亚洲欧美在线看 | 久草视频在线看 | 精品国产美女福到在线不卡f | 国产成人精品午夜免费 | www.成人网| 欧美成人精品一级高清片 | 91视频最新网站 | 日韩99精品| 国产91久久精品 | 在线高清免费爱做网 | 亚洲欧美国产视频 | 国产精品一区二区免费 | 欧美三级毛片 | 成人午夜精品久久不卡 | 中文国产成人精品久久一 | 中国一级特黄剌激爽毛片 | 黄色美女免费网站 | 久久精品国产亚洲 | 国产午夜精品一区二区 | 日本大臿亚洲香蕉大片 | 久草在在线视频 | 亚洲色视频在线播放网站 | 2018av男人天堂 | 国产精品成aⅴ人片在线观看 | 香蕉网影院在线观看免费 | 私人玩物福利视频 |