• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 541
  • Last Modified:

add extra column in 'select into'

selec top 0 *,getdate() into test from vw_gettabcount

gives an error, how can you add one extra column to the new table through the simple syntax?
0
anushahanna
Asked:
anushahanna
2 Solutions
 
anushahannaAuthor Commented:
select, i should be
0
 
käµfm³d 👽Commented:
You have to give "getdate()" and column name (alias):
select top 0 *,getdate() As DateColumn into test from vw_gettabcount

Open in new window

0
 
rockiroadsCommented:
what database? what is the error?

you could define the database field to default to current date on insert

0
 
anushahannaAuthor Commented:
the alias did the trick. thanks.
0
 
Rey Obrero (Capricorn1)Commented:
i don't think you can use " top 0 "
if you want to get only the table structure (no data) use this

select *,getdate() As myDate into test from vw_gettabcount where 1=0
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now