Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

select null as testdate into #temp_table

Is there a way to insert/update a datetime value (getdate()) into a temp table created like the following:

select id, null as testdate
into #temp_table

and then later statement:

update #temp_table 
set testdate=getdate()

I get error:

cannot convert datetime into int...

Thanks.

like image 976
Rod Avatar asked Sep 14 '10 18:09

Rod


1 Answers

Cast the column in the select into

select id, cast(null as datetime) as testdate
into #temp_table
like image 156
Mike Forman Avatar answered Oct 13 '22 00:10

Mike Forman