Peter DeBetta's blog about programming in SQL Server 2008, 2005, etc. using technologies such as T-SQL, .NET, CLR, C#, VB, Visual Studio, and SQL Server Management Studio.
So I just generated a DDL script using Visio and it uses quoted identifiers for all object names. But I don't like quoted identifiers and much more prefer bracketed identifiers. So how do I manage to replace all those pesky double quotes? Why, simply use "Find and Replace" in SQL Server Management Studio (SSMS)!
- SAVE THE SCRIPT FILE (just in case) before doing this operation!
- Open the Find and Replace dialog.
- At the bottom (in the "Find options") is a check box called "Use:". Check it.
- Select "Regular expressions" from the drop list below it.
- Then enter the following:
- Find what:
\"{<.@>}\"
- Replace with:
\[\1\]
- Click Replace All.
That's it, you now have bracketed identifiers for your objects.
WARNING: This changes all quoted text, including data in INSERT, UPDATE, or even DELETE statements, and therefore could cause issues with your data. This is meant to be used only with DDL scripts that contain no data. And please check before saving again and better yet, check the code into source control before doing the massive replace.
Comment Notification
If you would like to receive an email when updates are made to this post, please register here
Subscribe to this post's comments using
About Peter DeBetta
Peter DeBetta is an independent consultant specializing in design, development, implementation, and deployment of Microsoft SQL Server, Microsoft SharePoint Server, and .NET solutions. Peter writes courseware, articles, and books – most recently the title Introducing SQL Server 2008 from Microsoft Press. Peter speaks at conferences around the world, including TechEd, SQL PASS Community Summit, DevTeach, SQL Connections, DevWeek, and VSLive!
Peter is a Microsoft MVP for SQL Server, an MCP, President of the
North Texas SQL Server User Group, and a member of PASS.
When Peter isn’t working, you can find him singing and playing guitar (click
here to hear an original song by Peter), taking pictures, or simply enjoying life with his wife, son, and daughter.