October 27, 2011 at 10:13 am
I have a table in my sql server 2005 database where I need to replace all the values in one particular column with null values.
the column excepts NULL values and is currently populated with email addresses. I need to programatically replace all of the email addresses with a NULL Value.
Short of exporting the table, removing the email addresses and reimporting the data into the table, how can I do this with T-SQL?
October 27, 2011 at 10:21 am
is this as simple as an update?
update yourTable
set yourCol = Null
or am i missing something?
October 27, 2011 at 10:22 am
Hi as per the information provided by you, just a simple update will make all the values as null
update table set email=null
but not sure what exactly your requirement is, may be its not this much simple.
🙂
October 27, 2011 at 10:25 am
I think instead of making us guess its would better to post your DDL with some sample data and your desired output. 🙂
October 27, 2011 at 10:30 am
Assuming that your question is a serious need for assistance. Try this code
CREATE TABLE Atable(Id INT IDENTITY(1,1),EmailAdd VARCHAR(100))
INSERT INTO Atable
SELECT 'myaddress.gamail.com'
GO 10 --Add 10 records
--Check that EmailAdd column does not have Null value
SELECT * FROM Atable
UPDATE Atable SET EmailAdd = NULL
--Verify result
SELECT * FROM Atable
October 27, 2011 at 10:41 am
Thank you! The DDL
Create table dbo.TS_USERS (
TS_ID int not null,
TS_LOGINID VARCHAR(64) null,
TS_NAME VARCHAR(64) null,
TS_EMAIL VARCHAR(128) null,
Current results
TS_IDTS_LOGINIDTS_NAME TS_EMAIL
5login1 User1 user1@email.org
7login2 user2 user2@email.org
8login3 user3 user3@email.org
desired results
TS_IDTS_LOGINIDTS_NAME TS_EMAIL
5login1 User1
7login2 user2
8login3 user3
October 27, 2011 at 11:36 am
Update dbo.TS_USERS SET TS_EMAIL = NULL worked! Such a simple thing! Thank you for the help!
October 27, 2011 at 12:33 pm
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply