Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to run SQL Scripts in Visual Studio 2012

Posted on 2013-05-24
3
Medium Priority
?
513 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Accepted Solution

by:
Surendra Nath earned 900 total points
ID: 39195261
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 10

Expert Comment

by:Matt Bowler
ID: 39198336
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
ID: 39236238
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

610 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