Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
yalgaar
Starting Member
43 Posts |
Posted - 2006-02-25 : 10:47:45
|
| I have a table name "ABCD" When I run a Select statement on this table, it returns 100 rows. I would like to store this 100 records for future.In future I will have the same table with same sturcture. I want to insert this 100 rows into this table.Any suggestions.Thanks in Advance |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-02-25 : 12:12:20
|
| Store the PKs from your query in another table, with a "Batch number" column, and then access that in the future by use of the batch number?That would assess the data as-it-then-is from the ABCD table. If you must have the data from ABCD as-it-was-before then you'll need to store all columns.You may also need something that periodically deletes old, stale, rows in your second "batch" table.Kristen |
 |
|
|
yalgaar
Starting Member
43 Posts |
Posted - 2006-02-25 : 13:06:24
|
| Kristen, Thanks a lot for your reply, but I am not understanding it OR maybe I didn't explain my question well. Let me attempt to explain it 1 more time:I would like to store all rows that are returned by a select statement for future use of the data. How can I do that?In future, I will have a new table with the same structure, how can I import all the rows that were stored previuosly.FYI, I am a very newbie with SQL server.Thanks |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-02-25 : 13:09:41
|
| Either you store the keys to those rows, in another table, or your also store all the columns. Depends on whether, in the future, you need to be able to see the data "as it was", or just have a list of "which records" were in the original query (but then you would only be able to see the records as they are then - i.e. including any changes that have been made in the meantime).Might help if you explained the problem that you are trying to solve, rather than the solution you anticipate to your problem!Kristen |
 |
|
|
yalgaar
Starting Member
43 Posts |
Posted - 2006-02-25 : 13:18:07
|
| let me explain the problem:I have a table in a certain database. This table has 2000 rows. Only 200 rows are valid rows in this table. We have having several issues with other tables as well. So we are getting a brand new database. I do not care right now about other tables. All I care is about the 200 rows in this table which I would like to save it somehow so that I can import it later on when I have a brand new database with the brand new table.....do I make sense? |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-02-25 : 13:55:34
|
| You could make a temporary table, containing those rows:SELECT *INTO MyNewTemporaryTableFROM ABCDWHERE ... criteria for 200 valid rows ...You could transfer then to a new table in a different database (on the SAME server):SELECT *INTO MyOtherDatabase.dbo.MyNewTemporaryTableFROM MyCurrentDatabase.dbo.ABCD -- Only need database name if you are not SITTING IN IT!WHERE ... criteria for 200 valid rows ...and when you have your new server / database you could transfer directly to that server - however you will need to make a "LinkServer" to that server before this command is allowed: SELECT *INTO MyOtherServer.MyOtherDatabase.dbo.MyNewTemporaryTableFROM MyCurrentDatabase.dbo.ABCDWHERE ... criteria for 200 valid rows ...Kristen |
 |
|
|
|
|
|
|
|