修改下面的代码
怎样创建表时可以把变量和表名连起来不报错declare @time varchar(30)  
select @time= CONVERT(varchar(12),getdate(),112)  
set @time=right(@time,6)  
print @timecreate 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
)

解决方案 »

  1.   


    declare @time varchar(30)   
    select @time= CONVERT(varchar(12),getdate(),112)   
    set @time=right(@time,6)   
    print @timeEXEC('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
    )')