怎么让sql按时自动创建表
还有修改下面的代码
怎样创建表时可以把变量和表名连起来不报错
declare @time varchar(30)
select @time= CONVERT(varchar(12),getdate(),112)
set @time=right(@time,6)
print @time
create table VehicleTrail+@time
(
Sim varchar(11) not null,
TraceTime datetime not null,
Longitude float not null,
Latitude float not null,
Direction float not null,
Speed float not null,
MonitorType char(5) null,
GPSStatus bit not null
)
[解决办法]
[解决办法]
declare @time varchar(30)
select @time= CONVERT(varchar(12),getdate(),112)
set @time=right(@time,6)
print @time
declare @sql varchar(4000)
set @sql = 'create table VehicleTrail' + @time + '(Sim varchar(11) not null,TraceTime datetime not null,Longitude float not null,Latitude float not null,Direction float not null,Speed float not null,MonitorType char(5) null,GPSStatus bit not null)'
exec (@sql)
把这存为一个独立的sql文件
然后设计好计划任务,去调isql -U<user> -P<password> -S<> -i<sql文件> (以ASE为例)
如果是SQLServer,用osql就行了。