Solved

add extra column in 'select into'

Posted on 2010-09-16
5
533 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
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

772 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