婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > 一些SQL Server存儲過程參數(shù)及例子

一些SQL Server存儲過程參數(shù)及例子

熱門標簽:福州外呼系統(tǒng)招商 AI智能云呼電話機器人怎么注冊 溫州語音外呼系統(tǒng)排名 商家地圖標注圖片 怎么在高德地圖標注多個點 四川穩(wěn)定外呼系統(tǒng)公司 百度地圖標注信息怎么修改 沈陽外呼系統(tǒng)有效果嗎 電話機器人接口是什么樣的

Microsoft included several hundred stored procedures in the various versions of Microsoft SQL Server and it has documented a good percentage of them. But many stored procedures remain undocumented. Some are used within the Enterprise Manager GUI in SQL 2000 and were not intended to be used by other processes. Microsoft has slated some of these stored procedures to be removed (or they have been removed) from future versions of SQL Server. While these stored procedures can be very useful and save you lots of time, they can be changed at any time in their function or they can simply be removed.

The chart below shows that while many of the procedures have been carried through from one version of Microsoft SQL Server to another, new stored procedures have been introduced, and some have been removed from the install package. Most, if not all, of the procedures require the user to be a member of the sysadmin fixed server role in order to execute the procedures. The stored procedures that interact with the file system also require that the user executing the procedure (as well as SQL Server's service account) have access to the file/folder.

Procedure Name SQL 2000 SQL 2005 SQL 2008
sp_executeresultset X    
sp_MSforeachdb X X X
sp_MSforeachtable X X X
sp_readerrorlog X X X
xp_create_subdir   X X
Xp_delete_file   X X
xp_dirtree X X X
xp_fileexist X X X
xp_fixeddrives X X X
xp_getfiledetails X    
xp_getnetname X X X
xp_loginconfig X X X
xp_makecab X    
xp_msver X X X
xp_get_mapi_profiles X X X
xp_subdirs X X X
xp_test_mapi_profile X X X
xp_unpackcab X    

sp_executeresultset

Microsoft removed this handy little procedure called sp_executeresultset from SQL Server in SQL Server 2005. It allows you to generate dynamic SQL code on the fly by using a SELECT query. Then, the resulting SQL commands will be executed against the database. It permits you to create a single piece of code that can, in a single step, find the number of records in every table in your database (as the example shows). This is an undocumented stored procedure and there is no way of knowing why it was removed. But, alas, this handy utility is gone.

exec sp_execresultset 'SELECT ''SELECT '''''' + name + '''''',
count(*) FROM '' + name
from sysobjects
where xtype = ''U'''

sp_MSforeachdb / sp_MSforeachtable

Two procedures, sp_MSforeachdb and sp_MSforeachtable, are wrappers around a cursor. They allow you to execute T-SQL code against each database on your SQL Server and each table within the current database, respectively. You cannot, however, use an sp_MSforeachtable command within an sp_MSforeachdb command in SQL 2000 and prior. The cursor name that was used within those procedures was the same (hCForEach) and would therefore return an error saying that the cursor name was already in use for each execution of the sp_MSforeachtable. In SQL Server 2005, Microsoft resolved this issue. In order to "next" the command, you must tell one of the procedures it will be using a different replacement character other than the default question mark. I change the replacement character in the database command because it's easier.

Print each table name in the current database.

exec sp_MSforeachtable 'print ''?'''

Print each database on the current server.

exec sp_MSforeachdb 'print ''?'''

Print each table on the current server.

exec sp_MSforeachdb 'use [@] exec sp_MSforeachtable ''print
''''@.?''''''', '@'

sp_readerrorlog / xp_readerrorlog

The stored procedure sp_readerrorlog actually comes in two forms. Each works the same; one is simply a wrapper for the second. The wrapper stored procedure is sp_readerrorlog and it calls xp_readerrorlog. Both have four input parameters, but only the first two are useful to us. The first parameter establishes the file number that you wish to view. The second is the log to view (1 or null for ERRORLOG, 2 for SQL Agent Log). This allows you to view your error logs quickly and easily instead of having to look at the bloated log viewer that now comes with SQL Server 2005 and SQL 2008.

View the current SQL ERRORLOG file.

exec sp_readerrorlog

exec sp_readerrorlog 0, 1

View the Prior SQL Agent Log file.

exec sp_readerrorlog 1, 2

xp_create_subdir

Introduced in SQL Server 2005, the xp_create_subdir stored procedure is very handy because you can use it to create folders on SQL Server's hard drive or on a network share from within T-SQL.

exec xp_create_subdir 'c:\MSSQL\Data'

xp_delete_file

Use the xp_delete_file stored procedure introduced in SQL Server 2005 to delete files from SQL Server's hard drive or a network share from within T-SQL.

xp_dirtree

The xp_dirtree procedure allows you to view the folder tree and/or file list beneath a folder. This procedure has several parameters that control how deep the procedure searches and whether it returns files and folders or folders only. The first parameter establishes the folder to look in. (Recommendation: Do not run this procedure against the root of the drive that Windows is installed on because it will take some time to generate the tree and return the data.) The second parameter limits the number of recursive levels that the procedure will dig through. The default is zero or all levels. The third parameter tells the procedure to include files. The default is zero or folders only, a value of 1 includes files in the result set. Specifying a third value not equal to zero will add an additional column to the output called file which is a bit field showing the entry in a folder or file.

Get the full directory tree.

exec xp_dirtree 'd:\mssql\'

Get the first two levels of the directory tree.

exec xp_dirtree 'd:\mssql', 2

Get the first three levels of the directory tree, including files.

exec xp_dirtree 'd:\mssql\', 3, 1

xp_fileexist

This SQL Server stored procedure, xp_fileexist, is used to determine if a file exists on SQL Server's hard drive or on a network share. It is extremely useful in stored procedures that load data from flat files. It allows you to check and see if the file exists before attempting to blindly load the file. The procedure has two parameters. Use the first parameter to determine if the file or folder you want exists. The second is an output parameter, which when specified, returns a 1 or 0 if the file exists or does not.

Without the parameter.

exec xp_fileexist 'c:\importfile.csv'

With the parameter.

DECLARE @file_exists int
exec xp_fileexist 'c:\importfile.csv', @file_exists OUTPUT
SELECT @file_exists
 

xp_fixeddrives

The procedure xp_fixeddrives is one of the most useful procedures. It presents a list of all drive letters and the amount of free space each drive has. The parameter has a single optional input parameter that can filter the results by drive type. A value of 3 will return all mass storage devices (CD-ROM, DVD, etc.); a value of 4 will return the hard drives; while a value of 2 will return removable media (USB thumb drives, flash drives, etc.).

Return all drives.

exec xp_fixeddrives

Return hard drives only.

exec xp_fixeddrives 2

xp_getfiledetails

The procedure xp_getfiledetails is another extremely useful procedure, which was last available in SQL Server 2000. This procedure returns size, date and attribute information about the file specified, including date and times created, accessed and modified.

exec xp_getfiledetails 'c:\filetoload.csv'

xp_getnetname

The procedure xp_getnetname returns the name of the physical machine where Microsoft SQL Server is installed. You can have the machine name returned as a record set or as a variable.

Without the parameter.

exec xp_getnetname

Using the parameter.

DECLARE @machinename sysname
exec xp_getnetname @machinename OUTPUT
select @machinename
 

xp_loginconfig

This SQL Server stored procedure will tell you some basic authentication information about the user executing it. It tells you the authentication method (Windows versus SQL Login), the default domain of the server, the audit level, as well as some internal separator information.

exec xp_loginconfig

xp_makecab

Back in SQL Server 2000, Microsoft gave us the ability to compress OS files directly from T-SQL without having to shell out to DOS via xp_cmdshell and run third-party software, like pkzip or winzip. That command was xp_makecab. It allows you to specify a list of files you want to compress as well as the cab file you want to put them in. It even lets you select default compression, MSZIP compression (akin to the .zip file format) or no compression. The first parameter gives the path to the cab file in which you want to create or add files to. The second parameter is the compression level. The third parameter applies if you want to use verbose logging. Starting with the fourth parameter and on down are the names of the files you want to compress. In my testing, I was able to pass 45 file names to be compressed to the extended stored procedure, which means that it is a very flexible solution to your data compression requirements.

exec xp_makecab 'c:\test.cab', 'mszip', 1, 'c:\test.txt' , 'c:\test1.txt'

xp_msver

The procedure xp_msver is very useful when looking for system information. It returns a wealth of information about the host operating system -- the SQL version number, language, CPU type, copyright and trademark information, Microsoft Windows version, CPU count and affinity settings, physical memory settings and your product key. This procedure has many input parameters that allow you to filter down the records that are returned. Each parameter is a sysname data type, which accepts the name of one of the records. If any parameters are specified, only the rows specified as a parameter are returned.

No filter specified.

exec xp_msver

Return only Platform and Comments records.

exec xp_msver 'Platform', 'Comments'

xp_get_mapi_profiles

The xp_get_mapi_profiles procedure assists you in configuring SQL Mail. When executed, it will call to Windows via the SQL Mail component of SQL Server and display a list of available MAPI profiles that are configured in Outlook and it specifies which profile is the default profile. If it doesn't display any records, then either Outlook is not configured correctly or SQL Server is not running under a domain account with Outlook profiles configured. In order to use this procedure in SQL Server 2005 or SQL Server 2008, you must enable the "SQL Mail XPs" option in the Surface Area Configuration tool or within the sp_configure procedure.

exec xp_get_mapi_profiles

xp_subdirs

The xp_subdirs procedure displays a subset of the information avaialble through xp_dirtree. Xp_subdirs will display all the subfolders in a given folder. It can be very handy when you are building a directory tree within a table dynamically and you do not want to worry about the extra parameters of the xp_dirtree procedure.

exec xp_subdirs 'd:\mssql'

xp_test_mapi_profiles

The procedure xp_test_mapi_profiles is another undocumented stored procedure that is very useful when you are setting up SQL Mail. It will start, then stop, a MAPI session to ensure that MAPI is configured correctly and working within the confines of Microsoft SQL Server. I should note that it does not verify the mail server configuration within the MAPI client (Outlook) nor does it send a test message.

The procedure accepts a single input parameter. That parameter is the name of the MAPI profile you wish to test. Like the xp_get_mapi_profiles procedure, for this stored procedure to function in SQL Server 2005 and SQL Server 2008, you must enable the "SQL Mail XPs" option in the Surface Area Configuration tool or within the sp_configure procedure.

When working with the SQL Mail stored procedures, be aware that SQL Mail is still slated for removal from the Microsoft SQL Server platform. That means the procedures sp_get_mapi_profiles and xp_test_mapi_profiles are slated for removal, as they are part of the SQL Mail subsystem. You should do all mail work on SQL Server 2005 and later using Database Mail instead of SQL Mail to ensure code portability with future versions of SQL Server. Microsoft initially slated SQL Mail for removal in SQL Server 2008, however, based on its inclusion in the current beta release, its future in SQL Server 2008 is unknown.

xp_unpackcab

Along with the xp_makecab procedure comes the xp_unpackcab extended stored procedure, and it does just what it says: It extracts files from cab files. The first paramater is the cab file, the second is the path you want to extract to and the third is verbose logging. A fourth paramater lets you specify the "extract to" file name.

exec xp_unpackcab 'c:\test.cab', 'c:\temp', 1

While this is not intended to be a complete list of the undocumented stored procedures in SQL Server, it does provide a reference point for many of these procedures with the hope of making the lives of the SQL Server administrators easier. Remember, you should never count on these procedures surviving from one SQL Server version to the next, nor should you expect their code base to remain the same between versions. That said, go code and enjoy.

All information provided about Microsoft SQL Server 2008 (Katmai) is based on beta edition 10.0.1019 of the software and is subject to change without notice.

您可能感興趣的文章:
  • sqlserver存儲過程中SELECT 與 SET 對變量賦值的區(qū)別
  • SQL Server 2008 存儲過程示例
  • 如何在SQL Server 2008下輕松調(diào)試T-SQL語句和存儲過程
  • SqlServer獲取存儲過程返回值的實例
  • sqlserver 存儲過程中If Else的用法實例
  • sqlserver中查找所有包含了某個文本的存儲過程
  • Sql Server中存儲過程中輸入和輸出參數(shù)(簡單實例 一看就懂)
  • sqlserver 各種判斷是否存在(表名、函數(shù)、存儲過程等)
  • SQL Server 分頁查詢存儲過程代碼
  • SQL Server存儲過程同時返回分頁結(jié)果集和總數(shù)

標簽:無錫 寶雞 邯鄲 西寧 汕尾 七臺河 來賓 營口

巨人網(wǎng)絡(luò)通訊聲明:本文標題《一些SQL Server存儲過程參數(shù)及例子》,本文關(guān)鍵詞  一些,SQL,Server,存儲,過程,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《一些SQL Server存儲過程參數(shù)及例子》相關(guān)的同類信息!
  • 本頁收集關(guān)于一些SQL Server存儲過程參數(shù)及例子的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av
    亚洲天堂中文字幕| 亚洲成av人片一区二区| 亚洲尤物视频在线| 国产毛片一区二区| 91成人免费在线| 国产精品美女一区二区| 免费av成人在线| 在线视频中文字幕一区二区| 久久影院电视剧免费观看| 亚洲午夜久久久| 一本大道久久a久久精品综合| 2023国产精品视频| 日产国产高清一区二区三区| 色欧美乱欧美15图片| 国产精品三级电影| 成人免费视频国产在线观看| 精品国产免费一区二区三区四区| 水野朝阳av一区二区三区| 日本道色综合久久| 亚洲女人****多毛耸耸8| 福利一区二区在线| 国产欧美精品区一区二区三区 | 国产欧美日本一区视频| 久久精品国产成人一区二区三区 | 色综合久久久久| 中文字幕一区二区在线观看| 高清国产一区二区三区| 久久女同性恋中文字幕| 国内一区二区视频| 国产欧美一区二区精品忘忧草| 国产精品资源在线| 久久午夜老司机| 韩国女主播成人在线| 久久―日本道色综合久久| 国精品**一区二区三区在线蜜桃| 日韩视频在线永久播放| 韩国av一区二区三区| 久久久一区二区| 丁香六月久久综合狠狠色| 国产精品伦理在线| 风间由美中文字幕在线看视频国产欧美| 26uuuu精品一区二区| 国产精品99久久久久久似苏梦涵| 久久久久久久一区| zzijzzij亚洲日本少妇熟睡| ㊣最新国产の精品bt伙计久久| 91色.com| 日本色综合中文字幕| 久久久99精品免费观看不卡| 成人午夜在线播放| 一区二区欧美国产| 日韩欧美一级在线播放| 成人免费毛片片v| 亚洲国产乱码最新视频| 日韩一级在线观看| 成人午夜在线播放| 亚洲第一成年网| 精品福利一区二区三区| 99久久精品免费| 日日摸夜夜添夜夜添精品视频 | 中文幕一区二区三区久久蜜桃| 97超碰欧美中文字幕| 视频一区欧美精品| 欧美韩国日本一区| 欧美色区777第一页| 精品一区二区三区欧美| 亚洲视频一区在线| 日韩一区二区精品在线观看| 成人a免费在线看| 七七婷婷婷婷精品国产| 中文字幕一区三区| 日韩欧美亚洲国产精品字幕久久久| 成人18视频日本| 久久成人av少妇免费| 亚洲精品久久久蜜桃| 2017欧美狠狠色| 欧美精品色综合| 色综合久久综合网| 国产精品自拍av| 日本一道高清亚洲日美韩| 亚洲人被黑人高潮完整版| 日韩精品一区二区三区在线播放 | 亚洲欧美日韩在线播放| 26uuu亚洲综合色| 欧美精品自拍偷拍动漫精品| 99精品视频在线观看| 国产精品白丝jk黑袜喷水| 日本不卡不码高清免费观看| 樱桃视频在线观看一区| 国产精品乱码一区二区三区软件| 2021久久国产精品不只是精品| 5858s免费视频成人| 在线观看国产精品网站| 国产精品亚洲а∨天堂免在线| 美女网站在线免费欧美精品| 亚洲国产精品麻豆| 亚洲女人****多毛耸耸8| 国产精品国产a| 国产日产欧美一区二区三区 | 欧美一区二区三区四区视频| 精品视频123区在线观看| 不卡av在线网| 99这里只有久久精品视频| 成人理论电影网| 成人h精品动漫一区二区三区| 国产sm精品调教视频网站| 韩日av一区二区| 国产精品影视天天线| 狠狠色狠狠色综合日日91app| 久久精品av麻豆的观看方式| 美女在线视频一区| 国产综合一区二区| 国产传媒久久文化传媒| 成人精品电影在线观看| 成人一二三区视频| 99久久婷婷国产综合精品电影| 99热精品国产| 欧洲视频一区二区| 678五月天丁香亚洲综合网| 日韩一卡二卡三卡四卡| 欧美va亚洲va| 亚洲国产精品精华液ab| 国产精品成人网| 亚洲麻豆国产自偷在线| 亚洲自拍偷拍九九九| 日韩精品福利网| 国产一区亚洲一区| 成人高清av在线| 在线中文字幕一区| 9191久久久久久久久久久| 精品国产123| 国产精品另类一区| 亚洲一区二区三区四区五区黄| 日韩在线观看一区二区| 黄色日韩网站视频| 91浏览器在线视频| 欧美一区二区三区播放老司机| 精品欧美一区二区久久| 136国产福利精品导航| 婷婷夜色潮精品综合在线| 国内精品国产成人国产三级粉色| caoporen国产精品视频| 91精品福利视频| 欧美大黄免费观看| 亚洲美女视频在线| 激情深爱一区二区| 日本高清不卡视频| 26uuu精品一区二区三区四区在线| 亚洲欧美在线aaa| 美女网站色91| 日本高清不卡一区| 久久精品人人爽人人爽| 亚洲午夜电影网| 国产馆精品极品| 欧美日韩高清一区二区三区| 久久久久久久久久久久久久久99 | 久久精品国产一区二区三| 99视频在线精品| 久久综合给合久久狠狠狠97色69| 亚洲素人一区二区| 国产乱码精品一区二区三区忘忧草| 在线观看网站黄不卡| 中文字幕的久久| 精品无人码麻豆乱码1区2区 | 蜜臀av性久久久久av蜜臀妖精| 99久久精品国产观看| 欧美zozozo| 视频一区二区三区在线| 91玉足脚交白嫩脚丫在线播放| 精品黑人一区二区三区久久 | 青草国产精品久久久久久| av不卡免费电影| 中文字幕精品—区二区四季| 日本网站在线观看一区二区三区| 91黄色免费网站| 亚洲天堂精品在线观看| 国产1区2区3区精品美女| 精品理论电影在线观看| 日韩高清不卡一区| 欧美亚洲国产一区二区三区va| 国产精品国产三级国产普通话蜜臀 | 蜜桃av一区二区在线观看| 欧美三级韩国三级日本一级| 亚洲人123区| 一本色道a无线码一区v| 18欧美乱大交hd1984| 成人avav在线| 国产精品免费免费| 国产成人精品亚洲午夜麻豆| 久久久不卡影院| 激情小说亚洲一区| 久久午夜免费电影| 国产另类ts人妖一区二区| 国产午夜精品一区二区三区视频 | 国产精品久久综合| 国产一区二区主播在线| 久久久夜色精品亚洲| 国产v综合v亚洲欧| 亚洲啪啪综合av一区二区三区| 成人免费观看av|