可以用存储进程,最保险.
存储进程:
declare @curdate char(15) output
select
@curdate=str(datepart(year,getdate()),4,0)+str(datepart(month,getdate()),2,0)+str(datepart(day,getdate()),2,0)+''+str(datepart(hour,getdate()),2,0)+':'+str(datepart(minute,getdate()),2,0)
return 0
程序中定义一个TStoredProc,Tdatabase部件,StoredProc1的参数名为@curdate,类
型是output.配置database1的参数.
var
cudate:string;
begin
database1.connected:=True;
StoredProc1.DatabaseName:=Database.databasename;
Storedproc1.close;
Storedproc1.ExecProc;
cudate:=Storedproc1.ParamByName('@curdate').asstring;
Storedproc1.close;
end;