I am developing a small utility for my team which I want to use while deploying a database release. The developers are using management studio and whenever they make changes in an SP or table, they are creating scripts from management studio (DROP and CREATE) option.
In my utility, I use that script and when I run that script with ADO.Net execute non query, it throws several exceptions like - 'GO' is not correct keyword etc.
Can anyone please suggest what could be a way to run those scripts as is?
Thanks
Use of the Microsoft tools to run these scripts - they understand the GO command (which is not SQL) and strip it out before sending to SQL Server.
See sqlcmd and the older (deprecated) osql utilities.
Related
I'm working on an Angular / .Net core project, and I want to deploy it on my homemade server equipped with Windows Server 2016.
I'm stuck at figuring out the best way to create my database from my migrations files. I've seen some topics on stackoverflow about it, but I don't want to make mistakes on my server, so I'm asking for the best way to do that.
The first option I think is to install Visual Studio IDE on my server. Then I can open my project and run an Update-database command, which will read all migrations files and create database.
But I don't think I'm supposed to install Visual Studio on a server...
The second option is something I saw on StackOverflow. In my development environment, I can use the command dotnet ef migrations script, which will generate a script.
But I'm not sure where I should put this script. I think probably in Microsoft SQL Server Management studio, New query and put my script.
Could you please tell me the best way ?
you need dotnet sdk in order to use dotnet ef migrations script but you can use your development pc to connect to your remote SQL Server and do migrations. for this, just point your connection string to remote SQL Server and use either Update-Database or dotnet ef update database
Another solution exists and You can use SQL server Generate Script to query all your database objects and execute it on target SQL server.
The best way you can do "first create" of your database in production environment is to Generate Script from SSMS (SQL Server Management Studio) and run that script on production Db server. The reason of that is because your database is empty (you can put all of data in script) and you can easily change the name, etc.
After that, on new versions of your application, the best way is to use Update-Database -Script and save/add that script to your deployment scripts.
When you are preparing for go-live, try that scripts with ROLLBACK TRANSACTION, if something fails...
I searched SO for the solution but all answers means using interactive mode (SSMS) or third-party tools.
I need to obtain database creation script (with tables, SPs, triggers etc.) not from SSMS in interactive mode but from T-SQL or command line. There was SqlPubWiz utility in MSSQL older versions, but I cannot find it in 2014 (I use Express Edition).
So what should I do? Thank you.
Regarding the following images, I have obviously installed the Microsoft SQL Server, but I can't find the exe-file or anything named Microsoft SQL Server in the start menu.
Anyone who knows what to do to solve this, or do I need to install something more?
SQL Server runs as a service. You can start and stop it from windows services. SSMS is a gui tool for managing ddl (creating and altering tables and index's for example) and dml (writing queries to inquire, update or add data to databases).SSMS comes free with every edition of SQL server - perhaps you didn't tick a box when installing? You can also do this stuff the old fashioned way using sqlcmd from command line(DBAs love this for some reason) but for us mortals SSMS is much less of a struggle. As an aside there are other guis such as Toad (expensive) and Heidisql (free) amongst others which will do the job.
Looks like you have the engine. What you've got to do now is install SQL Server Management Studio: https://msdn.microsoft.com/hr-hr/library/mt238290.aspx
Looks like you have the various SQL Server components that are installed by Visual Studio (recent version) or SQL Server Data Tools (as used by VS).
I'm struggling to figure out how to batch modifications to our databases in SQL Server Management Studio. We'll perform actions like editing columns, creating tables, renaming tables, etc. that we need to perform on all of our environments - but not until we're ready to push the application. I'm trying to use the SQL profiler to grab the SQL but this seems horribly inefficient.
Is there a solution built into the application that will track such changes for me?
Looks like I found my answer: http://www.mssqltips.com/sqlservertip/1723/auto-generate-change-scripts-in-sql-server-management-studio-ssms-for-tables/
you can easily create scripts using the osql utility if you are on a version lower than SqlServer 2005.
From sql server 2005 onwards we use sqlcmd
I was thinking of the minimum software I can install on my new dev machine. Has anyone tried codeing with just VS2010/Linqpad?
The SQL Server is on another machine so then I would only need SSMS.. but then I think linqpad could replace that + help me with Linq queries..
But the problem seems to be I won't be able to CREATE SQL USERS with SSMS and I may need to do thatfrom time to time..
Any thoughts ?
Personally I'd always install SQL Management Studio as it's the defacto tool for managing SQL Server.
AFAIK you can't issue arbitary SQL commands using VS2010 and thus you can't create users - that is unless you use VS2010 to write an app to issue the commands which is trivial but I'd say ultimately pointless.
LINQPad lets you run SQL queries as well as LINQ queries - so you can manage without SSMS if you're happy to do things purely via SQL.
Of course, for some things SSMS is easier than writing SQL. And on a dev box you'll probably want SQL Profiler, too (for this reason, it's a good idea to install the management tools that come with the full edition of SQL Server rather than relying on the SQL Express tools).
I would install SQL Server client tools - you would at least then get SSMS and SQLCMD. No need for SQL Server itself (or even SSIS - you can still use BIDS to write packages, but you have to run them interactively).