---
title: "How to drops special characters OBJECT_ID in WHERE clause"  
description: "How to drops special characters OBJECT_ID in WHERE clause"  
author: "Samuel Fernandes"  
published: 2015-01-21  
updated: 2015-01-21  
canonical: https://www.mindstick.com/forum/12884/how-to-drops-special-characters-object_id-in-where-clause  
category: "mssql server"  
tags: ["sql server", "sql"]  
reading_time: 1 minute  

---

# How to drops special characters OBJECT_ID in WHERE clause

I'm using the query below to [identify](https://www.mindstick.com/forum/159425/java-app-crash-arrayindexoutofboundsexception-identify-invalid-index) [databases](https://www.mindstick.com/startup/34/airbyte-the-open-source-platform-simplifying-data-integration-for-warehouses-lakes-and-databases) for a drop-down list; it [works fine](https://answers.mindstick.com/qa/115732/my-software-works-fine-on-windows-10-but-crashes-on-windows-11-why), as long as the DatabaseName does not have any special [characters](https://answers.mindstick.com/qa/42112/who-is-the-originator-of-avengers-characters) (such as periods, commas, etc), but of course, we do want to include those. Now, when I run the [Select](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) statement by itself, it returns all of the [tables](https://www.mindstick.com/articles/336597/introduction-of-html-tables-for-web-development) correctly, but when I add in the WHERE [clause](https://www.mindstick.com/forum/33937/difference-between-throw-exception-and-throw-clause), it loses the tables with punctuation in the name. I'm sure that I have a [mistake](https://yourviews.mindstick.com/view/88393/ai-humanity-s-greatest-invention-or-final-mistake) in OBJECT_ID, but I just can't [figure](https://yourviews.mindstick.com/view/87536/what-are-ghosts-jobs-and-how-to-figure-out-them) it out.

SELECT [name] AS DatabaseName FROM sys.databases

WHERE OBJECT_ID ([name] + N'.[dbo].[tblInfo]', N'U') IS [NOT NULL](https://www.mindstick.com/interview/1933/what-is-not-null-constraint)

ORDER BY DatabaseName ASC

## Replies

### Reply by Anonymous User

QUOTENAME:

WHERE OBJECT_ID (QUOTENAME([name]) + N'.[dbo].[tblInfo]', N'U') IS NOT NULL

(Ditto for schema/table names that contain reserved characters)


---

Original Source: https://www.mindstick.com/forum/12884/how-to-drops-special-characters-object_id-in-where-clause

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
