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

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

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 數據庫
主站蜘蛛池模板: 欧美同性videos在线可播放 | 国产一区a| 在线观看国产精品日本不卡网 | 国产免费一区二区三区在线观看 | 亚洲国产精品久久卡一 | 热99re久久国超精品首页 | 中国黄色一级大片 | 成人国产在线24小时播放视频 | 国产在线爱做人成小视频 | 欧美在线a | 亚洲精品专区一区二区三区 | 91香蕉视频成人 | 欧美黑粗特黄午夜大片 | 欧美黄视频在线观看 | 精品视频国产狼人视频 | 国产一级一片免费播放 | 欧洲色老头| 国产成人精品福利网站人 | 国产成人精品日本亚洲专区6 | 日韩加勒比在线 | 欧美怡红院在线观看 | 国产在线一区在线视频 | 96精品免费视频大全 | 亚洲久久久久 | 91久久亚洲最新一本 | 最近中文在线中文 | 欧美一级性 | 国产精品特级毛片一区二区三区 | 日本美女黄色一级片 | 国产精品欧美亚洲 | 男女视频免费网站 | 高清亚洲| 亚洲国产品综合人成综合网站 | 国产欧美一区二区三区久久 | 欧美在线精品一区二区三区 | 国内国外精品一区二区 | 日本亚洲国产 | 伊人久久大香线焦在观看 | 欧美手机手机在线视频一区 | 国产亚洲国产bv网站在线 | 黄色美女视频免费看 |