Build SQL IN Clauses from Text: GUID and ID Lists

2026-07-03

Why you need SQL IN clauses

Filtering by a batch of IDs is everyday SQL:

SELECT * FROM dbo.Orders WHERE OrderId IN ('ORD-001', 'ORD-002', 'ORD-003');
SELECT * FROM dbo.Users WHERE UserId IN (1001, 1002, 1003);

When IDs come from an Excel column, logs, an API, or URL parameters, adding quotes and commas by hand is error-prone. ComTools Text to SQL (Tools/Excel/TextToSql) converts a text list into an IN (...) snippet locally in the browser—copy and paste into your full statement.

Supported input formats

Paste text and pick a delimiter:

Delimiter Typical use
Space aa bb cc or multiple GUIDs on one line
Newline Excel column copy, one ID per line
Comma id1,id2,id3
Period Special numbered lists
Custom e.g. ; or \|

Values are trimmed; empty tokens are dropped.

Input example (newline-separated GUIDs)

21d611b2-ca84-45bd-80e9-3456d0bf6ac5
bb6c33f3-f142-418d-8414-9b8f33b6f3da
7fe11ef1-2a3b-4c5d-9e8f-1234567890ab

Output example

IN (N'21d611b2-ca84-45bd-80e9-3456d0bf6ac5', N'bb6c33f3-f142-418d-8414-9b8f33b6f3da', N'7fe11ef1-2a3b-4c5d-9e8f-1234567890ab')

Strings use N'...' (Unicode); embedded quotes become ''.

Steps

  1. Open Text to SQL.
  2. Paste your ID list in the input pane.
  3. Choose the delimiter that matches your source (Excel column → usually newline).
  4. Click Generate; the output pane shows IN (...).
  5. Copy and paste into SSMS or your SQL client.

Full statement example:

SELECT * FROM dbo.ReportTools
WHERE ToolId IN (N'21d611b2-ca84-45bd-80e9-3456d0bf6ac5', N'bb6c33f3-f142-418d-8414-9b8f33b6f3da');

Common scenarios

Scenario Delimiter Next step
Excel column of OrderIds Newline Preview with SELECT before DELETE
Comma-separated GUIDs from URL Comma Pair with URL params parser
Space-separated IDs in logs Space Quick IN fragment
Verify before delete Newline SELECT COUNT(*) then batch delete

Work with Excel to SQL

Need Tool
Just an IN (...) snippet Text to SQL
Full DELETE / UPDATE per row Excel to SQL
Multi-column INSERT from sheet INSERT guide
Dedup IDs in Excel first Remove duplicates, then copy column here

Excel to SQL Select mode can also build WHERE col IN (...) from a whole sheet when IDs are not copied yet.

Notes

  • Numeric IDs: For int columns, remove N'...' quotes or use an unquoted number list.
  • Very long IN lists: May hurt plans and performance—consider temp tables or table-valued parameters.
  • Privacy: Processing is local in the browser; IDs are not uploaded.

FAQ

Why only IN (...), not a full SELECT?
It is a fragment so you can drop it into any WHERE clause. Use Excel to SQL for full Select statements.

Must GUIDs be uppercase?
Matching is case-insensitive on SQL Server; stay consistent with stored values.

Read directly from Excel files?
This tool is text-only—copy the column, or use Excel to SQL Select mode.


中文版