Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Replace empty string with No Data

Posted on 2013-05-29
7
Medium Priority
?
375 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 49

Expert Comment

by:PortletPaul
ID: 39206502
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
ID: 39206503
Empty string means "" not Null
0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 39206514
by the way, you should include sql server as a topic if asking sql server related questions
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 49

Expert Comment

by:PortletPaul
ID: 39206529
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
ID: 39206549
I need Select statment.
I know for IIF(condition,true,false)
0
 
LVL 49

Accepted Solution

by:
PortletPaul earned 2000 total points
ID: 39206561
>>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
ID: 39209179
Thanks a lot
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

662 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