久久福利_99r_国产日韩在线视频_直接看av的网站_中文欧美日韩_久久一

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

SQL Script tips for MS SQL Server

瀏覽:132日期: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 數據庫
主站蜘蛛池模板: 精品一区二区三区在线观看 | 四虎av在线| 成人免费看片 | 成人精品久久 | 久久久久国产一级毛片高清版小说 | 欧美成人精品一区二区三区 | 日本免费三片免费观看 | 日韩一区在线视频 | 久久久www成人免费无遮挡大片 | 波多野结衣 一区二区三区 精品精品久久 | 亚洲一区在线日韩在线深爱 | 成人av一区二区三区 | 欧美一级毛片日韩一级 | 中文字幕乱码一区二区三区 | 欧美日韩国产一区二区三区不卡 | 乱人伦xxxx国语对白 | 一本一道久久a久久精品逆3p | 特级生活片 | 亚洲中出 | 国产精品1区二区 | 欧美一级在线 | 男人天堂99 | 成人网在线观看 | 亚洲一区二区在线播放 | 欧美精品亚洲精品日韩精品 | 高清国产午夜精品久久久久久 | 亚洲欧美激情精品一区二区 | 91中文字幕 | 欧美精品一区二区在线观看 | 日韩综合网 | 久久精品视频免费观看 | 久久精品这里热有精品 | 精品视频在线观看一区二区 | 亚洲国产区 | 国产一区二区免费 | 亚洲一区成人在线观看 | 日韩午夜电影 | 国产日韩一区二区三免费高清 | 国产成人精品久久二区二区 | 国产在线综合视频 | 91一区二区 |