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.Aaron Bertrand– Aaron Bertrand2016年02月26日 15:14:01 +00:00Commented Feb 26, 2016 at 15:14
-
would still mean having to rename every single file (of which there are many)adolf garlic– adolf garlic2016年02月26日 15:30:04 +00:00Commented Feb 26, 2016 at 15:30
-
1No, 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?Aaron Bertrand– Aaron Bertrand2016年02月26日 15:32:10 +00:00Commented 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.
-
That sounds like it is from SQL Server 2014 - I was asking regarding 2012 (as tagged). Useful to know neverthelessadolf garlic– adolf garlic2016年02月29日 11:57:38 +00:00Commented Feb 29, 2016 at 11:57
-
Works for any version of SQL Server. SSDT is the key here, not SQL Server.spaghettidba– spaghettidba2016年02月29日 11:58:45 +00:00Commented 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 thatadolf garlic– adolf garlic2016年02月29日 14:44:10 +00:00Commented Feb 29, 2016 at 14:44