午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

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

SQL Script tips for MS SQL Server

瀏覽:204日期: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 數據庫
主站蜘蛛池模板: 日韩在线视频第一页 | 久久综合狠狠综合久久综合88 | 国产做a视频 | 午夜视频在线观看视频 | 韩国精品一区二区三区 | www.天天干 | 日本成人在线免费 | 一级成人免费视频 | 在线成人免费 | 蜜臀99久久精品久久久久小说 | 91视频二区 | 国产精品爽爽久久 | 国产精品久久久999 成人激情视频在线 | 国产一区在线观看免费 | 成人福利在线视频 | 亚洲综合一区二区 | 在线看片成人 | 欧美一区二区三区爽爽爽 | 国产哺乳奶水91在线播放 | 一区二区三区国产 | 国产日韩欧美91 | 亚洲一区二区三区在线观看视频 | 一本一道av| 欧美一区二区三区久久久 | 毛片大全免费 | 一本到在线视频 | 情侣在线视频 | 欧美a v | 玖玖成人| 成人免费一级片 | 三级自拍视频 | 婷婷一区二区三区 | 精品亚洲成人 | 国产剧情精品 | 超碰免费在线播放 | 午夜精品久久久久久久99黑人 | 中文字幕在线播放不卡 | 国产精品久久久久久久成人午夜 | 久久久91视频 | 一二三不卡视频 | 国产午夜网站 |