欧美阿v视频在线大全_亚洲欧美中文日韩V在线观看_www性欧美日韩欧美91_亚洲欧美日韩久久精品

主頁 > 知識庫 > 一些SQLServer存儲過程參數及舉例

一些SQLServer存儲過程參數及舉例

熱門標簽:申請400電話在哪辦理流程 電銷外呼有錄音系統有哪些 臨沂智能電銷機器人加盟哪家好 外呼運營商線路收費 百度地圖標注改顏色 小e電話機器人 一個導航軟件能用幾個地圖標注點 貴州房產智能外呼系統供應商 鎮江網路外呼系統供應商

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存儲過程參數及舉例》,本文關鍵詞  一些,SQLServer,存儲,過程,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《一些SQLServer存儲過程參數及舉例》相關的同類信息!
  • 本頁收集關于一些SQLServer存儲過程參數及舉例的相關信息資訊供網民參考!
  • 推薦文章
    欧美阿v视频在线大全_亚洲欧美中文日韩V在线观看_www性欧美日韩欧美91_亚洲欧美日韩久久精品
  • <rt id="w000q"><acronym id="w000q"></acronym></rt>
  • <abbr id="w000q"></abbr>
    <rt id="w000q"></rt>
    在线观看亚洲成人| 亚洲一区二区三区四区在线观看| 石原莉奈在线亚洲三区| 日本少妇xxxx软件| 色狠狠桃花综合| 中文欧美字幕免费| 国产成人在线网站| www.99re6| 中文字幕av一区二区三区免费看| 国产原创一区二区三区| 日本人亚洲人jjzzjjz| 久久理论电影网| 国产一区二区三区四区在线观看| 少妇无套高潮一二三区| 久久久综合九色合综国产精品| 免费在线一区观看| 国产 欧美 在线| 欧美精品一区二区三区高清aⅴ| 免费高清视频精品| 亚洲国产日韩综合久久精品| 成人免费视频国产在线观看| 色国产精品一区在线观看| 伊人婷婷欧美激情| av av在线| 日韩亚洲电影在线| 美女被吸乳得到大胸91| 五月天精品在线| 国产精品无遮挡| www.在线成人| 欧美日韩精品一区二区| 午夜视频在线观看一区二区三区| 亚洲成av人片在线观看无| 日韩免费性生活视频播放| 久久国产欧美日韩精品| 日本黄色录像视频| 亚洲美女免费视频| 7788色淫网站小说| 久久久综合激的五月天| 成人午夜免费av| 欧美三电影在线| 日韩国产在线一| 亚洲一二三精品| 亚洲人精品午夜| a天堂视频在线观看| 2020国产精品自拍| 成人黄色网址在线观看| 欧美美女喷水视频| 精品一区二区三区久久| 国产va在线播放| 午夜影院久久久| 手机av在线不卡| 一区二区三区欧美亚洲| 亚洲永久精品ww.7491进入| 欧美国产精品劲爆| 69xxx免费视频| 久久嫩草精品久久久精品| 不卡一区中文字幕| 欧美一卡二卡三卡| 国产精品亚洲综合一区在线观看| 在线亚洲一区二区| 麻豆freexxxx性91精品| 日本电影欧美片| 免费欧美日韩国产三级电影| 日韩成人毛片视频| 日韩中文字幕91| 黄色a级片在线观看| 日韩和欧美一区二区| 欧美成人777| 男人操女人的视频在线观看欧美| 超碰手机在线观看| 免费成人在线观看| 在线日韩av片| 国产在线精品一区二区三区不卡| 在线观看日韩精品| 国产中文一区二区三区| 欧美日韩精品欧美日韩精品| 国产一二三精品| 在线播放中文一区| 国产91精品露脸国语对白| 91精品国产黑色紧身裤美女| 粉嫩aⅴ一区二区三区四区 | 在线观看日产精品| 韩国精品在线观看| 欧美日韩mp4| 精品va天堂亚洲国产| 三上悠亚 电影| 日本一区二区综合亚洲| 国产一级二级在线观看| 亚洲欧美日韩国产手机在线| 亚洲一区二区三区日韩| 亚洲第一二三四区| 美国黄色小视频| 国产一区二区精品久久91| 91精品国产欧美一区二区18| 91浏览器入口在线观看| 亚洲国产成人一区二区三区| 90岁老太婆乱淫| 午夜精品久久久久久久| 91极品视觉盛宴| 懂色av中文字幕一区二区三区 | 91免费国产在线观看| 国产亚洲va综合人人澡精品| 亚洲制服丝袜在线播放| 亚洲最大成人综合| 日本高清免费不卡视频| 成人综合婷婷国产精品久久免费| 精品国产一区二区三区忘忧草 | 亚洲美女区一区| 91成人福利视频| 国产精品2024| 久久精品一区二区三区不卡| 久久精品成人av| 欧美aⅴ一区二区三区视频| 在线成人av影院| 又色又爽又黄18网站| 亚洲男人的天堂av| 色婷婷香蕉在线一区二区| 国产精品乡下勾搭老头1| 久久久精品一品道一区| japanese中文字幕| 麻豆精品一区二区三区| 日韩精品专区在线影院观看| 一本色道综合久久欧美日韩精品| 午夜激情一区二区| 在线播放中文字幕一区| 免费日本黄色网址| 亚洲丶国产丶欧美一区二区三区| 欧美探花视频资源| 中文字幕一区二区三区人妻在线视频 | 欧美视频三区在线播放| 91色在线porny| 亚洲乱码中文字幕| 在线中文字幕一区| 无码人妻丰满熟妇区毛片蜜桃精品 | 国产精品一区二区亚洲| 国产乱国产乱300精品| 久久久久久久综合色一本| 人妻无码一区二区三区免费| 国产风韵犹存在线视精品| 亚洲国产高清不卡| 一本到不卡精品视频在线观看| av在线播放不卡| 一区二区激情小说| 欧美男生操女生| 最近日本中文字幕| 久久爱www久久做| 国产午夜精品久久久久久久| 色偷偷www8888| 成人动漫视频在线| 亚洲一区二区影院| 91精品国产乱码久久蜜臀| 五月天综合视频| 成人免费看视频| 亚洲综合久久久久| 欧美一级久久久| 超碰人人人人人人人| 成人激情文学综合网| 亚洲精品国久久99热| 欧美一区二区私人影院日本| 婷婷色一区二区三区| 国产精品亚洲一区二区三区在线| 亚洲天天做日日做天天谢日日欢| 欧美日韩美少妇| 国产精品揄拍100视频| 国产精品一区二区x88av| 亚洲免费看黄网站| 欧美日韩精品一区二区三区蜜桃| 欧美性xxxx图片| 国产精品一区二区免费不卡| 一区二区三区欧美久久| 日韩欧美区一区二| 波多野结衣亚洲一区二区| 亚洲欧美综合视频| 精品一区二区在线观看| 亚洲视频一二三| 日韩一二三区不卡| 亚洲精品一区二区三区在线播放| 91捆绑美女网站| 精品一区二区三区在线播放| 日韩理论电影院| 精品国产免费久久| 欧洲人成人精品| 亚洲AV无码国产成人久久| 成人精品一区二区三区中文字幕| 午夜欧美一区二区三区在线播放| 久久久www免费人成精品| 欧美性淫爽ww久久久久无| 亚洲色成人网站www永久四虎| 99国产精品久久久久| 毛片av一区二区| 樱桃视频在线观看一区| www激情久久| 欧美日韩一区成人| 国产wwwwxxxx| 三级视频网站在线观看| 久久综合999| 欧美影片第一页| 午夜精产品一区二区在线观看的| 黄页网站在线看| 国产精品18久久久|