e.g. if you run the 'generate scripts' function (by right clicking on a db in object explorer) to script out an entire database, it creates all the files in one folder and annoyingly names them as [schema.objectname].[objecttype].sql

(at least if it were type.name it might be a little more readable)

Fine but I would rather mirror the object explorer convention of having Tables, Views, etc on a per folder basis containing only those object types and the file having exactly the same name as the object

Is there a simple way to achieve this?

  • Simplest would be to script the different types separately. Feb 26, 2016 at 15:14
  • would still mean having to rename every single file (of which there are many) Feb 26, 2016 at 15:30
  • 1
    No, if you create a folder called Stored Procedures, then script all stored procedures to that folder, then create a folder called functions, and script all functions to that folder - your goal was to separate them by folder, right? Why would you need to rename files? Feb 26, 2016 at 15:32

1 Answer 1


You could import the database definition in SSDT using the "Schema Compare" tool.

Simply create an empty database project, right click and select "Schema compare". Select the project as target and the live database as source. Click "Compare" and then "Update": SSDT will script all objects and add them to your project.

SSDT by default creates a folder for each schema and in each folder creates separate folders for tables, stored procedures, views and so on.

SSDT tree

  • That sounds like it is from SQL Server 2014 - I was asking regarding 2012 (as tagged). Useful to know nevertheless Feb 29, 2016 at 11:57
  • Works for any version of SQL Server. SSDT is the key here, not SQL Server. Feb 29, 2016 at 11:58
  • Well it's not part of the standard SQL 2012 install and I don't have admin rights on my machine. So that's that Feb 29, 2016 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.