2

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?

asked Feb 26, 2016 at 14:57
3
  • Simplest would be to script the different types separately. Commented Feb 26, 2016 at 15:14
  • would still mean having to rename every single file (of which there are many) Commented 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? Commented Feb 26, 2016 at 15:32

1 Answer 1

2

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

answered Feb 26, 2016 at 16:25
3
  • That sounds like it is from SQL Server 2014 - I was asking regarding 2012 (as tagged). Useful to know nevertheless Commented Feb 29, 2016 at 11:57
  • Works for any version of SQL Server. SSDT is the key here, not SQL Server. Commented 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 Commented Feb 29, 2016 at 14:44

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.