How do I create Stored Procedure in MSSQL without Management Studio? - sql-server

I have a customer who is not interested in installing MSSQL Management Studio. And I need to add one Stored procedure in the Database for my application to communicate.
Is it possible to create the stored procedure in MSSQL Server without Management Studio?
FYI, I can export the .sql file for Stored procedure from my system.
Solved
Solutions based on the answers:
SQLCMD (installed with SQL Server)
Azure Data Studio

You can use...
SSDT (SQL Server Data Tools)
SQLCMD
PowerShell

You could see if your client would be willing to install Azure Data Studio (formerly SQL Operations Studio). It's a quicker install than SSMS.

Related

How to convert server based database to local database(MDF to SDF) C#?

Windows application in C# cannot connect to database without SQL Server installed. I created a Windows Forms application in Visual Studio (2013) using C#, for customers info. I created the database with SQL Server and then imported to Visual Studio with data sources.
But it's not working without SQL Server installed. Maybe I need some sort of .MDF to .SDF conversion, but do not need a server database just local database is required.
You can use my SQL Server Compact Toolbox to move schema and data from SQL Server to SQL Server Compact

Can not modify stored procedure on Azure

I'm new to Azure SQL database.
I managed to migrate my database to the cloud.
Now I'm trying to modify a stored procedure using Microsoft SQL Server Management Studio (the latest edition - 2014). But get the following error message:
USE statement is not supported to switch between databases. Use a new
connection to connect to a different database.
Any idea how can I do this?
Also, is there any alternatives to Microsoft SQL Server Management Studio to work with Azure SQL Database?
USE in sql is used to switch between databases not to modify stored procedures. You cannot use USE on Azure SQL as per the specification. You should be able to right-click on the database name in Microsoft SQL Server Management Studio (SSMS) and select New Query, or you can use the dropdown list in the menu to switch databases. You can then use ALTER PROCEDURE (https://msdn.microsoft.com/en-GB/library/ms189762.aspx) to alter your procedure.
You can use Visual Studio as an alternative to SSMS but IMHO Visual Studio is not as productive. It doesnt matter which client you use though, because USE wont work in any of them.

SQL Server 2014 backup to 2012

Are there any tools to convert SQL Server 2014 database to 2012?
I tried Generate Script but the generated script with data is too large and SQL Server Management Studio did not execute it, I need to have both schema and data.
To my knowledge, there are basically three two options for migrating a database to a lower version of SQL Server, without using 3rd party tools:
Generate Scripts (not really suitable for large amounts of data)
Custom Scripting and BCP or Import/Export Wizard
SQL Server Integration Services (Transfer Database Task)
First option is not suitable in your case, as noted.
Second option is to simply script the structure of the database, and then use the Import/Export Wizard to copy the data, one table at a time. Note, that if you have foreign key constraints in your database, you might want to disable the constraints until after you have populated all your tables with data. This blog post explains in details how this can be done.
Third option uses the SISS Transfer Database Task which basically uses SMO to create the objects on the destination server and then transfers the data. This is the recommended way of migrating a database between SQL Server instances of different versions. SSIS requires that you have installed SQL Server Data Tools - Business Intelligence (SSDT-BI) for Visual Studio. Before SQL Server 2012, this was called Business Intelligence Development Studio (BIDS). You can download these here:
Microsoft SQL Server Data Tools - Business Intelligence for Visual Studio 2013
Microsoft SQL Server Data Tools - Business Intelligence for Visual Studio 2012
If you don't have Visual Studio, SSDT-BI / BIDS is included in the SQL Server installation.
Use the script, but instead of executing it trough Management Studio, use the lightweight sqlcmd utility.
http://msdn.microsoft.com/es-es/library/ms162773.aspx
Oh well, Dan's second option does not work: after installing SSDT-BI for VS2013 and configuring the Database Transfer Task it says that the version of the source database instance has to be lower or equal to the version of the destination database instance: so, a migration from 2014 to 2012 (or in my case 2008R2) is not possible.

Alternate option for SQL Server 2008 Management Studio Express

I am trying to install SQL Server 2008 Management Studio Express found here, but I am getting a win32 not an application error.
Is there another option for managing Windows SQL Server databases other than Visual Studio? I just have to be able to log in to the server and run some test SQL like:
ALTER TABLE test ADD column VARCHAR(50)
Can you run that query in Visual Studio? If so that would solve the problem too.
There is the command line sqlcmd utility.
The sqlcmd utility lets you enter Transact-SQL statements, system procedures, and script files at the command prompt, in Query Editor in SQLCMD mode, in a Windows script file or in an operating system (Cmd.exe) job step of a SQL Server Agent job.
Yes, you can run ad-hoc queries to a SQL Server database from Visual Studio.
Find/create a Data Connection in Server Explorer, right-click, and choose New Query.

extract schema for sql server compact edition

Is there a way to generate the sql statement for tables in sql server compact ?
same as for sql server express+ ?
Essentially a create table( .... ) statement as output ?
There is a project on Codeplex that someone has actually built the functionality to be able to do scripting for sql server compact edition databases.
There is a tool to do this. Check out http://www.antipodeansoftware.com/Home/Products
This will iterate the entire SQL server, and write all the table, view, stored procedure and UDF scripts to a local drive. Great for adding SQL schema or DDL to source control.
The plugin SQLite & SQL Server Compact Toolbox has versions for Visual Studio and SQL Server Management Studio. I've used the latter version successfully to add columns and export the schema as CREATE TABLE statements from SQL Server Compact Edition 3.5.
You can connect to SQL Server Compact Edition using SQL Server Management Studio(SSMS), which in turn allows you to script out all database objects.
Please refer to: Managing SQL Server Compact Edition with SQL Server Management Studio
and then also, How to: Generate a Script

Resources