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
779 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SqlServer Table Triggers 3 28
SQL Select - identify record discrepancies 1 31
SQL Throw Error 7 34
Connect remotely to SQL Server DB without TCP/IP enabled? 2 35
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…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

749 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