Solved

Replace empty string with No Data

Posted on 2013-05-29
7
328 Views
Last Modified: 2013-05-30
I have a field1 text type in MS access table1 that could have empty string in.

I need to create select statement that will work in Access and SQL Server to replace empty string to “No Data”
Something as replace function, however replace is not working in SQL Server, not sure with Nz too.

Any idea?
0
Comment
Question by:Taras
  • 4
  • 3
7 Comments
 
LVL 48

Expert Comment

by:PortletPaul
Comment Utility
does "empty string" mean "null"? (I will assume it does.)

syntax differences between the 2 products may preclude a single solution

sql server:

isnull([field1],'no data')
case when [field1] is null then 'no data' else [field1] end

in access: (I think, not my strength)

nz([field1],"no data")
iif(isnull([field1]),"no data",[field1])
0
 

Author Comment

by:Taras
Comment Utility
Empty string means "" not Null
0
 
LVL 48

Expert Comment

by:PortletPaul
Comment Utility
by the way, you should include sql server as a topic if asking sql server related questions
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 48

Expert Comment

by:PortletPaul
Comment Utility
ok, my bad - wasn't sure

I think you face the same sort of issues however in that syntax differs between the 2 products.

sql server:

case when [field1] ='' then 'no data' else [field1] end

in access: (I think, not my strength)

iif([field1]="","no data",[field1])
0
 

Author Comment

by:Taras
Comment Utility
I need Select statment.
I know for IIF(condition,true,false)
0
 
LVL 48

Accepted Solution

by:
PortletPaul earned 500 total points
Comment Utility
>>I need to create select statement that will work in Access and SQL Server to replace empty string to “No Data”

I am unable to suggest one that will work in both - which was my point really. Perhaps someone else can.

select -- sql server
case when [field1] ='' then 'no data' else [field1] end as field1
from [dbo].[table1]

select -- access, I think
iif([field1]="","no data",[field1]) field1
from [table1]

I'd be more than happy to provide a more comprehensive query, but I only know of [field1] & [table1]

{+ edit sorry a typo fixed}
0
 

Author Closing Comment

by:Taras
Comment Utility
Thanks a lot
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

11 Experts available now in Live!

Get 1:1 Help Now