declare @test as DATETIME
set @test='21/03/2014'
print @test
select @test
set @test=21/03/2014
print @test
select @test
set @test=21-03-2014
print @test
select @test
set @test=03/21/2014
print @test
select @test
set @test=2014/21/03
print @test
select @test
set @test=2014/03/21
print @test
select @test
此代码提供了错误的输出,因此请告诉我在SQLServer 2008中分配datetime变量的代码
答案 0 :(得分:6)
declare @test datetime
set @test='03/21/2014'
//set @test='21/03/2014' This is not valid you must give date in MM/dd/yyyy
print @test
set @test='2014/03/21'
print @test