Solved

add extra column in 'select into'

Posted on 2010-09-16
5
532 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
5 Comments
 
LVL 6

Author Comment

by:anushahanna
Comment Utility
select, i should be
0
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 425 total points
Comment Utility
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
Comment Utility
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
Comment Utility
the alias did the trick. thanks.
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

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…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now