Sybase ASA中幾個非常有用的存儲過程 以下過程非常實用: www.2cto.com 1. Send UDP包到指定地址: sa_send_udp CALL sa_send_udp( '10.25.99.196', 2345', 'This is a test' ); 2. 獲取當前系統中活躍的事務列表: call sa_transactions( ) 3. 有用的tsql 環境設置 CREATE PROCEDURE dbo.sp_tsql_environment() BEGIN IF db_property( 'IQStore' ) = 'Off' THEN -- SQL Anywhere datastore SET TEMPORARY OPTION close_on_endtrans='OFF'; END IF; SET TEMPORARY OPTION ansinull='OFF'; SET TEMPORARY OPTION tsql_variables='ON'; SET TEMPORARY OPTION ansi_blanks='ON'; SET TEMPORARY OPTION chained='OFF'; SET TEMPORARY OPTION quoted_identifier='OFF'; SET TEMPORARY OPTION allow_nulls_by_default='OFF'; SET TEMPORARY OPTION on_tsql_error='CONTINUE'; SET TEMPORARY OPTION isolation_level='1'; SET TEMPORARY OPTION date_format='YYYY-MM-DD'; SET TEMPORARY OPTION timestamp_format='YYYY-MM-DD HH:NN:SS.SSS'; SET TEMPORARY OPTION time_format='HH:NN:SS.SSS'; SET TEMPORARY OPTION date_order='MDY'; SET TEMPORARY OPTION escape_character='OFF'; END 4. 執行操作系統命令 xp_cmdshell system procedure Carries out an operating system command from a procedure. xp_cmdshell( 'dir > c:\\temp.txt', 'no_output' ) 5. 讀取寫入文件 xp_read_file xp_write_file 6. 獲取某一個表的 DDL語句 sa_get_table_definition system procedure select row_value from sa_split_list( sa_get_table_definition('DBA', 'ttt'), char(10)); row_value CREATE TABLE "DBA"."ttt" ( "abc" timestamp NULL ) ; 7. 發送郵件 CALL xp_startsmtp( smtp_sender = '[email protected]', smtp_server='smtp.163.com', smtp_port='25', timeout=240, smtp_auth_username='iihero', smtp_auth_password='***'); CALL xp_sendmail( recipient='[email protected]', subject='New Pricing'); call xp_stopmail();