Solved

SQL - set certain records to nothing - not null or zero - as if no data was in the columns for selected rows

Posted on 2006-03-21
11
775 Views
Last Modified: 2010-07-27
HI ,

I am trying to update certain rows of a dbase and set certain columns in the rows to nothing. Someone has entered zeros in these columns and I need to update the table and set the rows back to empty (not null or zero)


have tried "  " and '  '  but getting  syntax errors. What can I use to set the rows back to empty as if there was no data there ?

thanks.
0
Comment
Question by:pabby061203
11 Comments
 
LVL 9

Expert Comment

by:paelo
ID: 16249269
UPDATE dbo.yourtable
SET yourfield=NULL
WHERE yourfield=0



-Paul.
0
 
LVL 11

Expert Comment

by:star_trek
ID: 16249757
>>>>>>I need to update the table and set the rows back to empty (not null

"nothing" IS null. So if you want to set tjose rows to nothing 0 can't be used as it is int, " " cannot be used as it is varchar... and it is not "nothing".  SO it shld be null

so the query shld be
update <tablename>
set <column>=null WHERE <column>=0
                         
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16250192
>>What can I use to set the rows back to empty as if there was no data there ?<<
If you do not want to use Null, than try this:

Update YourTableName
Set YourColumnName = ''
Where YourColumnName = '0'
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16250207
Also, the following question is considered abandoned, please attend to it:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21709703.html
0
 

Author Comment

by:pabby061203
ID: 16256180
Hi again and thanks.


I have found that it is slightly more complicated now. There are complete rows in this table that have been populated with a zero in each cell. I need to identify where the complete rows of zeros are - there may be other rows that have one or two zeros in them - I don't need to update those rows - it is only where a row is totally populated with zeros -not partially populated.


The column names are  Question1, question2, question3, question4 and question5. Tablename is tblanswers.
any ideas ?

thanks again.




0
 

Author Comment

by:pabby061203
ID: 16256470
Hi ,

I have solved this one myself ,  I used  

update tblanswers
set question1 = ' ' where question1 = 0 and question2 = 0 and question3 = 0 and question4 = 0 and question5 = 0


then I ran the same statement to set question2 = ' ' where question1 = 0 etc etc etc etc

thanks
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16264985
>>I have solved this one myself <<
Great! Now please close the question.
0
 

Author Comment

by:pabby061203
ID: 16267917
HI.

I would like to close this question but am not seeing where to do this . Can you point me in the right direction,

thanks
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16276891
>>Can you point me in the right direction<<
Sure.  It is all covered in the EE Help:

What are my choices?
http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/help.jsp#hi67

Accept an Expert's Comment as the Answer http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/help.jsp#hi68
Accept Comments from more than one Expert (a Split) http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/help.jsp#hi69
Request a refund because you answered your own question (Refund/PAQ) http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/help.jsp#hi70 
Request a refund because no one answered your question (Delete) http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/help.jsp#hi71 
Abandon your question and leave the mess for someone else to clean up http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/help.jsp#hi78
0
 

Accepted Solution

by:
GranMod earned 0 total points
ID: 16325099
Closed, 125 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question