Solved

replace is null in all columns with a blank

Posted on 2010-08-31
15
478 Views
Last Modified: 2012-05-10
i need a sql sentence for remove all is null with a ' '

like this
update ramales set at12=' ' where at12 is null

but all at once

is that posible??
thank you experts

0
Comment
Question by:edo60
  • 4
  • 3
  • 2
  • +5
15 Comments
 
LVL 6

Accepted Solution

by:
apresence earned 500 total points
ID: 33570408
For Microsoft SQL Server:
ISNULL(curwages, 0) + ISNULL(curselfemployed, 0) + ISNULL(curtaxreturn, 0) AS wages
0
 
LVL 6

Expert Comment

by:apresence
ID: 33570416
Ignore that, posted answer to the wrong question
0
 
LVL 1

Expert Comment

by:rajmraji
ID: 33570465
the only way i can think  of is to write a query that gets you all the columns in your tables (loking at the syscolumns, systables, etc) and build a dynamicall executed series of string that do what you have above to each column...
0
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 33570471
Your code works correctly for all records, do you mean all columns?
0
 

Author Comment

by:edo60
ID: 33570555
all columns that have nulls

thank you a lot
0
 
LVL 5

Expert Comment

by:almander
ID: 33570757
You do not really even need a where clause.
update ramales set  at12 =  IsNull(at12, ' ')

Open in new window

0
 
LVL 69

Expert Comment

by:ScottPletcher
ID: 33570786
UPDATE ramales
SET at12 = CASE WHEN at12 IS NULL THEN ' ' ELSE at12 END,
       otherCol01 = CASE WHEN otherCol01 IS NULL THEN ' ' ELSE otherCol01 END,
       otherCol02 = CASE WHEN otherCol02 IS NULL THEN ' ' ELSE otherCol02 END,
       otherCol03 = CASE WHEN otherCol03 IS NULL THEN ' ' ELSE otherCol03 END,
      --...
       otherCol30 = CASE WHEN otherCol30 IS NULL THEN ' ' ELSE otherCol30 END
WHERE at12 IS NULL
    OR otherCol01 IS NULL
    OR otherCol02 IS NULL
    OR otherCol03 IS NULL
    --....
    OR otherCol30 IS NULL
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 58

Expert Comment

by:cyberkiwi
ID: 33570982
update ramales set
at12=coalesce(at12, ' '),
at13=coalesce(at13, ' '),
at14=coalesce(at14, ' '),
at21=coalesce(at21, ' '),
at22=coalesce(at22, ' ')


List your columns using this pattern.
0
 
LVL 11

Expert Comment

by:Larissa T
ID: 33571826
Why you don't like nulls? They are useful...

This select will produce update statements for all nullable columns in your database. Add other datatypes as needed
copy printed statement and  and execute in sql.
Use "where" in updates if you can. Without where It will produce many more transaction in you transaction log and will run longer

select t.name, c.name,
'update '+ t.name +' set '+c.name+'='''' where '+c.name+' is null '
from sysobjects t
join syscolumns c on t.id = c.id
join systypes ty on c.xtype=ty.xtype
where t.type = 'U' and t.status > 0 and ty.name in ('char','nchar','nvarchar','varchar') and isnullable = 1
order by t.name, c.name
0
 

Author Comment

by:edo60
ID: 33572835
i know there are usefulls
but in a sql command in crystal reports 8
do not put me all the string if one of the values is null
then i need blanks for acomplish this task of display a string in crystal reports

thank you a lot
0
 
LVL 4

Expert Comment

by:parthmalhan
ID: 33573915
Your Query is allright
0
 

Author Comment

by:edo60
ID: 33578972
its right , but when find a null in the string
do not display
is this

(select("a48"+"a42"+"a36"+"a30"+"a24"+"a20"+"a18"+"a16")
from ramales
where (pos=8)and (proyecto="Proyectotmp"."Proyecto")and (spec="paso"."spec")
)
0
 

Author Comment

by:edo60
ID: 33578976
is any way to fix it from the report?
tjhank you a lot
0
 
LVL 5

Expert Comment

by:almander
ID: 33579050
In my opinion, it is best to create a view, and access that view in crystal. Handling nulls in Crystal can get quite cumbersome. Not to mention that if it encounters a null, it stops processing a statement.

I would create a view similar to below to handle the nulls. And map to the view in crystal.
select IsNull(a48,'')+IsNull(a42,'')+IsNull(a36,'')+IsNull(a30,'')+IsNull(a24,'')+IsNull(a20,'')+IsNull(a18,'')+IsNull(a16,'') AS YOUR_FIELD_NAME

from ramales 

Open in new window

0
 
LVL 5

Expert Comment

by:almander
ID: 33579084
To fix this in the report you should select the columns individually.

SELECT a48, a42, a36
etc...

Then create a formula to concatenate the string, testing nulls.

IIF(IsNull({a48}), "", {a48}) + IIF(IsNull({a48}), "", {a42}) + IIF(IsNull({a48}), "", {a36})
etc...
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

947 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now