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 |
taniarto
Starting Member
27 Posts |
Posted - 2013-03-04 : 21:33:29
|
Dear All,I have 2 table the name is IVheader and Ivdetail. Ivheader is storing Sales header record (such id trans,date, total qty,total value) and ivdetail is storing transaction detail (such as id trans,itemid, qty, unit price and subtotal). I want to backup data from a range of record both of them. for example I want to back up transaction from '2013-03-01' until '2013-03-15' and than restore it again into another database on another location.Does anyone can help ?Thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-04 : 22:54:00
|
are databases in same server? if yes, you can simply use INSERT...SELECT to insert required data from main table to your backup table. Then you may purge it from main table if you want. it will be likeINSERT INTO DB2.dbo.BackupTableSELECT column1,column2,...FROM DB1.dbo.MainTableWHERE datefield >=@StartDateAND datefield< @EndDate +1 also see herehttp://visakhm.blogspot.in/2012/12/different-ways-to-implement-date-range.html------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
taniarto
Starting Member
27 Posts |
Posted - 2013-03-05 : 03:50:53
|
does the syntax can be use for exporting the result into a text file and then import it again into database? because it is different database and different location there's no connection between both of them..thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-05 : 03:53:51
|
for that you need to use bcp or OPENROWSETthen you can again apply bcp in or BULK INSERT to insert it back------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|