?
Solved

add extra column in 'select into'

Posted on 2010-09-16
5
Medium Priority
?
538 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 1700 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 300 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

741 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