我在批处理文件(.bteq文件)中写了一些SQL命令,bteq文件如下:
.logon localhost:1025/dbc,dbc
SELECT 1 FROM dbc.tables WHERE databasename = 'customerservice' AND TABLENAME
= 'accounts';
.if activitycount <>0 then drop table customerservice.accounts;
CREATE SET TABLE CustomerService.accounts ,FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO
(
ACCOUNT_NUMBER INTEGER NOT NULL,
STREET_NUMBER INTEGER,
STREET CHAR(25) CHARACTER SET LATIN NOT CASESPECIFIC,
CITY CHAR(20) CHARACTER SET LATIN NOT CASESPECIFIC,
STATE CHAR(2) CHARACTER SET LATIN NOT CASESPECIFIC,
ZIP_CODE INTEGER,
BALANCE_FORWARD DECIMAL(10,2),
BALANCE_CURRENT DECIMAL(10,2))
UNIQUE PRIMARY INDEX ( ACCOUNT_NUMBER );
insert into customerservice.accounts
values(20031303,559,'LaSalleAve','SantaMonica','CA',94123,4550.00,4550.00);
insert into customerservice.accounts values(20033587,506,'SomersetWay',
'HermosaBeach','CA',90365,7770.00,7770.00);insert into
customerservice.accounts
values(20033118,900,'9thStreet','HermosaBeach','CA',90365,3080.00,3080.00);
insert into customerservice.accounts values
(20032649,924,'OregonTrail','HermosaBeach','CA',90365,8200.00,8200.00);
insert into customerservice.accounts values
(20030691,987,'ComptonPlace','SantaMonica','CA',94123,8240.00,8240.00);
然后我像这样运行这个bteq文件:
bteq < test.bteq 2>error.txt
我想要的是将错误重定向到error.txt,但似乎它不起作用,也许是因为2只是标准错误,但SQL错误不是标准系统错误? 如果是这样,那么我们有什么方法可以将SQL错误重定向到文件吗?