Solved

add extra column in 'select into'

Posted on 2010-09-16
5
537 Views
Last Modified: 2012-08-14
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
Comment
Question by:anushahanna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 6

Author Comment

by:anushahanna
ID: 33694133
select, i should be
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 425 total points
ID: 33694188
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
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 75 total points
ID: 33694198
what database? what is the error?

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

0
 
LVL 6

Author Comment

by:anushahanna
ID: 33694239
the alias did the trick. thanks.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 33694244
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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question