0

Hi everyone.

I'm relatively new to MS SQL but one of my clients has a site based entirely around it so I am having to get to know it a bit better.

While trying to clean out some of the fake emails from the mail list table they all got deleted.

I have CSV backups of the table, is there any way of importing the CSV into the table with out destroying any new entries into the table?

The table consists of 2 fields, one auto incrementing number and the email address.

The database is on a thirdparty host server and I use SQL Management Studio Express 2005 to manage the database.

Any help at all would be greatly appreciated.

Thanks

Jim

5
Contributors
10
Replies
12
Views
8 Years
Discussion Span
Last Post by cgyrob
0

Sure you can. What I would is import the .CSV file to another table then:

SET IDENTITY_INSERT dbo.Email ON

Insert Into Email (IdentityColumn, EmailColumn)
Select IdentityColumn, EmailColumn
From NewEmailTable
Where
NOT EXISTS
(
  Select *
  From Email (NOLOCK)
  Where Email.IdentityColumn = NewEmailTable.IdentityColumn
)


SET IDENTITY_INSERT dbo.Email OFF

You can use that to match identities but more than likely depending on if you had activity before/after the delete and whether or not your table was truncated (which would reset the identity seed value) you may have overlapping identity values with different email data. In this case you could use the same query but test to see if the email exists, and not the identity.

I hope this helps and good luck, data recovery is never fun.

0

Sure you can. What I would is import the .CSV file to another table then:

Thanks for your response, it does help but the trouble I am having is getting that first bit done. How do I actually go about importing the CSV?

0

Open Microsoft SQL Server Management Studio, expand the server, expand database, Right click on the database --- Tasks --- Import Data, Click next, for choose data source pick "Flat File", navigate to the file, and away you go

0

Open Microsoft SQL Server Management Studio, expand the server, expand database, Right click on the database --- Tasks --- Import Data, Click next, for choose data source pick "Flat File", navigate to the file, and away you go

I don't have that option in my menus. I'm using Microsoft SQL Server Management Studio Express 2005.

Any other suggestions?

0

Sure you can. What I would is import the .CSV file to another table then:

SET IDENTITY_INSERT dbo.Email ON

Insert Into Email (IdentityColumn, EmailColumn)
Select IdentityColumn, EmailColumn
From NewEmailTable
Where
NOT EXISTS
(
  Select *
  From Email (NOLOCK)
  Where Email.IdentityColumn = NewEmailTable.IdentityColumn
)


SET IDENTITY_INSERT dbo.Email OFF

You can use that to match identities but more than likely depending on if you had activity before/after the delete and whether or not your table was truncated (which would reset the identity seed value) you may have overlapping identity values with different email data. In this case you could use the same query but test to see if the email exists, and not the identity.

I hope this helps and good luck, data recovery is never fun.

I agree with this just import the .CSV file to another table

0

I don't have that option in my menus. I'm using Microsoft SQL Server Management Studio Express 2005.

Any other suggestions?

In the object explorer click the (+) beside the "<Server name>" then the (+) beside the "Databases" then right click the "<name of your database>" select "tasks" then select "Import Data". That's how you do it. I also use SQL Server Management Studio 2005.

0

@yangski

The user said he was using express which does not include SSIS which is used for the import wizard. The link Sknake provided has a blog on the subject and some possible solutions.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.