Solved

Query about SELECT INTO copying table

Posted on 2014-02-06
6
285 Views
Last Modified: 2014-02-06
Hi,
If I copy a table using SELECT * INTO xyz from abc, then would that new table XYZ fetch new rows when old table ABC will be updated?
Or any other method to create a copy and it gets automatically updated?
0
Comment
Question by:fireblues
6 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 35 total points
ID: 39839090
>would that new table XYZ fetch new rows when old table ABC will be updated?
No.  It's a single action, and once it's complete there is no relationship / connectivity between xyz and abc.

>Or any other method to create a copy and it gets automatically updated?
Explain your needs to us, and we'll propose something.
0
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 35 total points
ID: 39839097
>Or any other method to create a copy and it gets automatically updated?
You need to create insert/update triggers for this ..
0
 

Author Comment

by:fireblues
ID: 39839145
I have a table ABC. One column in ABC needs to be updated for the purpose of creating report. So I cannot make update on ABC.
ABC is a live table, so it keeps updating.
Can I create a procedure? Can you show me how?
Thanks everyone for your replies.
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 65

Expert Comment

by:Jim Horn
ID: 39839176
>One column in ABC needs to be updated for the purpose of creating report.
Spell this out for us, as in most companies updating a production table to reflect anything dealing with reporting is bound to get you some unwanted attention.
0
 
LVL 69

Expert Comment

by:ScottPletcher
ID: 39839402
Create a separate reporting table, for example "ABC_Report_Data", with the key column(s) from table ABC.  Put your new data column(s) in that table.  You can join to/from ABC using the key column(s).

For example:

CREATE TABLE dbo.ABC (
    key_col int ...,
    data_col1 ...,
    data_col2 ...,
    ...
    )

CREATE TABLE dbo.ABC_Report_Data (
    key_col int ..., --FK --> dbo.ABC ( key_col )
    report_col ...
    )
0
 

Author Comment

by:fireblues
ID: 39841025
Thanks Guys!!! I resolved the problem using several Inner Joins.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 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

25 Experts available now in Live!

Get 1:1 Help Now