Closed

Need TSQL for Emergency. Live System.

Hi, a program I was running which rebuilds tables messed up a clients database wiping out over $300000. All the data is still there, just in new tables prefixed with an X

for example ... InvoiceHeader (now empty), is called XInvoiceHeader

What I have managed to do so far is this

Code: select Name, case when left(name, 1) = 'x' then substring(name, 2, 50) else name end as Rename, Object_ID

INTO #DC_TEMP

from [url removed, login to view]

where name not like 'xhs%'

order by rename, name

A sample of the results ...

Code: select * from #DC_TEMP

Name_______Rename______Object_ID

Access Access 1768354060

XAccess Access 1209732058

AcctAccess AcctAccess 1800354174

XAcctAccess AcctAccess 1257732229

ACode ACode 1832354288

XACode ACode 1305732400

ActionCond ActionCond 1864354402

XActionCond ActionCond 1353732571

ActionDetail ActionDetail 1896354516

XActionDetail ActionDetail 1401732742

So for the first row, the 1st and 2nd columns have the same name, so what I need to do is make sure the script sees that, it means its an original table.

Code: SELECT COUNT(*) FROM Access

If that comes back as 0 then I want to take the Rename column and rename the table to Rename+'_BAK'

Then take the second line XAccess and rename it to Access, essentially putting all the data back in the right spot

Skills: Database Administration, SQL

See more: database emergency tsql, substring c, c substring, code sys, tsql, sys, emergency, name empty, database system sql, sql select order, select name, administration system example, rename code, sql select script, database sample program access, live code, substring, program order system, system sql program, access database order system, empty access, database system access, access order system, access program sample, sql database tables

About the Employer:
( 0 reviews ) Perth, Australia

Project ID: #1301409

11 freelancers are bidding on average $180 for this job

HussienSharaf

HI, I m the best expert in SQL and TSQL. I can construct a script that will do this job. Regards, Dr. Hussien Sharaf

$220 AUD in 2 days
(16 Reviews)
6.7
tejas34

Hi, I have 8+ years of experience in MSSQL, MySql & MSAcess database implementation and management. I will defenatially resolve your problem. I will need some more details from your side. Please go through my feedb More

$250 AUD in 1 day
(17 Reviews)
5.1
sikandermandal

Please See PMB.

$150 AUD in 1 day
(9 Reviews)
4.6
pradeepsingh37

I am a SQL Server database administrator with over 7 years of experience in production support. I am a Microsoft Certified Technical Specialist in SQL Server 2008.

$250 AUD in 3 days
(12 Reviews)
4.4
anhouse

Hi. We can help you. With SQL - oh don't count years

$250 AUD in 1 day
(3 Reviews)
3.8
DeoTech

Hi! I work with MS SQL since 1999. Kindly ee PM. Regards.

$150 AUD in 1 day
(5 Reviews)
3.6
eirikureiriksson

Script will be delivered within 24hours.

$150 AUD in 0 days
(0 Reviews)
0.0
Sukii

Hello, According to your requirement i can write a sql query. Let me know the how Is there any join or something.

$60 AUD in 1 day
(0 Reviews)
0.0
instaDBA

Hi, I have over 10 years experience as a SQL Server DBA. Most of this time was spent at banks and insurance companies. I can take care of this within the next 12 hours if you want. Regards, Brian

$250 AUD in 1 day
(0 Reviews)
0.0
harigopal

Dear DaveC86, I am a microsoft certified SQL Server developer with more than 5 years experience. As per my understanding you need a script which when run should get the data in your new tables (x prefixed ones) More

$100 AUD in 0 days
(0 Reviews)
0.0
netw0rker

Hi, the easiest thing will be do restore your datasase if it was backed up. Always a good a idea to do this when making schematic changes. I'd be more than happy to help you, I have over 10 years in SQL programming and More

$150 AUD in 1 day
(0 Reviews)
0.0