Solved

How to run SQL Scripts in Visual Studio 2012

Posted on 2013-05-24
3
473 Views
Last Modified: 2013-06-10
I just installed Visual Studio 2012, having previously been on 2008. I need to work on SQL scripts, and be able to run selected lines of SQL within the .sql file. I'd also like to create a project to store all my scripts, which relate to the same scope of work. I've created the database project and imported all the .sql files that I need (that I had previously developed in SSMS), but I can't find a way to run those scripts against the desired database. I don't seem able to set up a database reference, or I just don't know how to do that, but I'm not certain that's what I need to do. I'm also not certain that I can do what I want within the structure of a database project, but that's where I am right now. I've figured out how to do one-off files, as in SSMS, but I was hoping this would help me organize my work better.

Any suggestions anyone?
0
Comment
Question by:DanielBorson
3 Comments
 
LVL 16

Accepted Solution

by:
Surendra Nath earned 300 total points
Comment Utility
you can do that

in the menu check for SQL --> Transact SQL editor --> New Query.
This will open a new query window for you to execute your SQL within visual studio.
0
 
LVL 9

Expert Comment

by:MattSQL
Comment Utility
Visual Studio 2012 database projects are mainly geared towards database deployment scripts. If you have SQL Server installed locally you can use SQL Server Management Studio - this will allow you to keep scripts together in projects and define connection managers etc...
0
 

Author Comment

by:DanielBorson
Comment Utility
I had figured out how to do a query, but VS12 is not really set up for complex queries in the same way that SSMS is. I ended up installing SSMS separately and using that. It had initially appeared that I could finally do it all in one tool, but alas, that was not the case.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now