Sql-server – Preventing SQL Server Data Tools from Inserting Spaces in Object Names

sql serverssasvisual studio

Is there any way to prevent SQL Server Data Tools and Visual Studio from introducing spaces into object names when creating dimensions, mining structures and the like from data source views (DSVs)?

For example, if you happen to have columns named WordCount and IsList defined in your DSV, the SSDT/Visual Studio GUIs will automatically change the names to "Word Count" and "Is List." Although this may be more "end-user-friendly," it can cause a lot of problems if your goal is to tightly synchronize object names with the relational objects the DSV columns are derived from; for example, scripts that try to make some kind of statistical comparison between the relational column and data calculated upon it in a cube may fail because the object names are different. It can also cause difficulties in synchronizing report writing and documentation generation. It's cumbersome to have to manually remove the spaces that SSDT/Visual Studio introduce (as well as risky, given that these tools are notoriously temperamental when it comes to juggling metadata, leading to all kinds of obscure SSAS errors) so I'd like to shut off this "feature" permanently if possible. Thanks in advance.

Note that I did not indicate an edition of SSDT or Visual Studio because I have yet to see one that doesn't exhibit this behavior.

Best Answer

I don't think it's possible to turn the "feature" off, but the way it works is that it interprets caps and underscores as a new word so a field in your datasource MyAttribute or my_attribute becomes a member named My Attribute.

The only way I can think of to prevent this is to have your column names all lower case without underscores in your datasource so myattribute as a column name will stay myattribute as your member name.

I'm not sure how your comparison scripts work and how you generate them, but I think you'll have to resort to either removing the space when you generate an SQL query or parsing and adding a space according to the same logic when generating your MDX. In powershell that should be fairly easy.