• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 543
  • 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?
2 Solutions
anushahannaAuthor Commented:
select, i should be
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

what database? what is the error?

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

anushahannaAuthor Commented:
the alias did the trick. thanks.
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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