Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the SQL File Template in Visual Studio 2010?

I notice in VS2010's Tools > Options dialog, there is a section on how to format the SQL:

PL/SQL Options

I am working with a very large stored procedure on our server that is not formatted well at all. I was thinking it would be great to create a new SQL File in my project, copy and paste the text from the stored procedure in there, and have the text editor apply auto formatting to all of the SQL.

When I call "Add > New Item" and get that dialog, there does not seem to be any Installed Template with the .sql extension.

Add New Item Dialog

I see the SQL Server Database template, but that is not what I need. The LINQ to SQL Classes is not right, either.

What template do I need to use to use the auto formatting built into the VS2010 interface?

like image 514
jp2code Avatar asked Feb 25 '14 15:02

jp2code


People also ask

How do I view SQL database in Visual Studio?

To connect to a database instance In Visual Studio, make sure that SQL Server Object Explorer is open. If it is not, click the View menu and select SQL Server Object Explorer. Right-click the SQL Server node in SQL Server Object Explorer and select Add SQL Server.

Where is the .SQL file?

The default database file location for server instances depends on the version of the Microsoft SQL Server software: SQL Server 2014 — C:\Program Files\Microsoft SQL Server\MSSQL12. MSSQLSERVER\MSSQL\DATA\ SQL Server 2016 — C:\Program Files\Microsoft SQL Server\MSSQL13.

How do I create a SQL file in Visual Studio?

Right-click your project in Visual Studio and select "Add->Existing Item" Then you can find the sql file and click "OK" button to add it into your project. At last, click the sql file and in the properties window to set the "Build Action" to "Embedded Resource"


1 Answers

Judging from your screenshot, you have a C# project (e.g. a library dll) open. This won't show an option to add a .sql file as those files are not normally associated with a C# kind of projects.

One way around it is:

  1. In VS2010 main menu, go to File -> New -> File. In General tab, there's a SqlFile file type. enter image description here

  2. Add a file and save it to the disk in the location of your project.

  3. Right-click on your project and select Add -> Existing Item. In the open file dialog, change the extension to *.* to show your .sql file.

  4. Add file to the project. If needed, change "Build Action" and "Copy to Output Directory" properties to control how it behaves during the build.

like image 168
Szymon Avatar answered Sep 22 '22 09:09

Szymon