Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / General / Other SQL Server Topics / January 2007

Tip: Looking for answers? Try searching our database.

Update bad addresses

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris - 27 Jan 2007 00:23 GMT
I got got a pile of bad email addresses to update in our SQL database.
I know how to do this for individual records using the update command.
Is there a way to execute an update using the list of addresses in an
excel spreadsheet or some other form of list?  This kind of scripting
is new territory for me.
Steve - 27 Jan 2007 02:32 GMT
If your Excel file has a column matching the the Primary Key of the
database table, in addition to the email address column, you can use
DTS(2000) or SSIS(2005) to import it into a table and use an INNER JOIN
in you UPDATE.

> I got got a pile of bad email addresses to update in our SQL database.
> I know how to do this for individual records using the update command.
> Is there a way to execute an update using the list of addresses in an
> excel spreadsheet or some other form of list?  This kind of scripting
> is new territory for me.
Chris - 29 Jan 2007 23:11 GMT
Unfortunately I just have the email addresses.

I know I can get the primary key for an individual record using a
select statement like the one below.
use maindb
go
select *
from dbo.tblLead
where email = 'bad@address.com'

Is there a way to use the excel list in the place of the single bad
address and then dump the results into a new table?  Then do the
update as described below as a separate process?  If I wanted to just
delete bad addresses where I don't have a new address and leave the
rest of the lead information alone could I do that using an Inner join
in my update?  All references I have found to the delete statement
talk about deleting entire rows of data and I don't want to do that.

Chris

> If your Excel file has a column matching the the Primary Key of the
> database table, in addition to the email address column, you can use
[quoted text clipped - 6 lines]
> > excel spreadsheet or some other form of list?  This kind of scripting
> > is new territory for me.
Ed Murphy - 30 Jan 2007 05:04 GMT
> Unfortunately I just have the email addresses.
>
[quoted text clipped - 13 lines]
> in my update?  All references I have found to the delete statement
> talk about deleting entire rows of data and I don't want to do that.

Say you create a table (tblBadAddresses) with one column (email) and
dump the Excel data into it, then the next step is as follows:

update tblLead
set email = null
where email in (select email from tblBadAddresses)
Chris - 29 Jan 2007 23:24 GMT
Unfortunately I only have a list of addresses.  I know I can retrieve
the primary key associated with an individual address using the
following select statement or somehting similar.

use leaddb
go
select primary_key, email
from dbo.tblLead
where email = 'bademail@address.com'

Is it possible to use a variable in the where statement that picks up
the data in the excel file and then dumps the results into a table for
the purposes of doing the update as described below?  Also if I don't
have a new address to update with how do I delete the email address
but leave the rest of the record in tact?  All of the references I
have seen to the DELETE statement refer to deleting rows from the
table.  I don't want to do that - only the email address.

> If your Excel file has a column matching the the Primary Key of the
> database table, in addition to the email address column, you can use
[quoted text clipped - 6 lines]
> > excel spreadsheet or some other form of list?  This kind of scripting
> > is new territory for me.
Andrew J. Kelly - 27 Jan 2007 03:08 GMT
Your best bet is to import the addresses using DTS or SSIS and then doing an
update join.

Signature

Andrew J. Kelly SQL MVP

>I got got a pile of bad email addresses to update in our SQL database.
> I know how to do this for individual records using the update command.
> Is there a way to execute an update using the list of addresses in an
> excel spreadsheet or some other form of list?  This kind of scripting
> is new territory for me.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.