亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

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

SQL Script tips for MS SQL Server

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

主站蜘蛛池模板: 国产中的精品一区的 | 国产精品麻豆高清在线观看 | 一级做a爰片久久毛片唾 | 免费看国产精品久久久久 | 韩国毛片免费看 | 日韩精品a| 清纯唯美亚洲综合 | 久久精品成人欧美大片免费 | 成人免费久久精品国产片久久影院 | 国产美女久久久亚洲 | 免费看毛片的软件 | 久久本道综合色狠狠五月 | 72种姿势欧美久久久久大黄蕉 | 无码中文字幕乱在线观看 | 男人都懂的www网站免费观看 | 日韩免费一级a毛片在线播放一级 | 女人被狂躁免费视频 | 欧美成人午夜剧场 | 亚洲国产成人精品91久久久 | 一级中文字幕 | 在线观看黄色毛片 | 一级骚片超级骚在线观看 | 黄色电影毛片 | 黄大色大片免费久久 | 国产首页精品 | 麻豆国产精品入口免费观看 | 久久欧美精品欧美久久欧美 | 操亚洲美女 | 国产高清狼人香蕉在线观看 | 欧美日韩免费播放一区二区 | 日韩 亚洲 欧美 中文 高清 | www.亚洲国产 | 免费在线观看视频网站 | 国产精品视频99 | 四色在线| 看一级毛片免费观看视频 | 黄色毛片在线看 | 日韩毛片在线播放 | julia一区福利视频在线观看 | 青青草一区二区免费精品 | 中国一级特黄的片子免费 |