Editing Stored Procedures in MSSQL Server 2008 - sql

I imported a database for MSSQL 2008 for development. I know they have stored procedures because I was able to edit them live with the web interface front that they have.
Now that I have the database loaded in a development location how do I access them? Are they normally stored in a table? I see at least one table with stored procedures. Is there a way to edit them with a built in text editor?
EDIT: I do have SQL Management Studio installed, just not sure how exactly to access/edit the procedures.

Normally you would use SSMS - SQL Server Management Studio to do this. Its usually included with SQL Server, so you may just need to install it.
http://msdn.microsoft.com/en-us/library/ms174173.aspx
or download it here:
http://www.microsoft.com/en-us/download/details.aspx?id=7593

Got it!
So different from working with MySQL.
In Object Explorer, connect to an instance of Database Engine and
then expand that instance.
Expand Databases, expand the database in which the stored procedure
belongs, and then expand Programmability.
Expand Stored Procedures, right-click the procedure to modify, and
then click Modify.
Modify the text of the stored procedure.
To test the syntax, on the Query menu, click Parse.
To modify the stored procedure, on the Query menu, click Execute.
To save the script, on the File menu, click Save As. Accept the file
name or replace it with a new name, and then click Save.

try like this:
If You Installed SQL SERVER Management Studio then Type ssms in RUN
Select Installed SQL SERVER Instance and Log in
Then Type Below command, it gives you Text of stored procedure
sp_helptext 'Procedure_name'

Related

Tool bars and Stored Procedures - Service Reporting (SQL)

I have two small problems with Reports, I am using SQL Server and SSRS.
I am deploying reports through VS Shell (Report Sever Project).
I make a report, do settings, all things ok.
When I click Preview(VS Shell), the tool bar looks like:
But when I access the report in browser(IE), it looks like:
Do you know how I can resolve it?
The second problem is about stored procedures. When I open the SSMS (Sql Sever Management Studio) -> Programability -> Stored Procedures, I see all stored procedures.
The problem is when I try to use a stored procedure in VS Shell , I don't see them.
Do you have any idea why?
Question
I am not sure but i think this is a IE problem - tried any other browser?
Question
I often used stored procedures as source for reports, but NEVER used Query tpye "Stored Procedure" - didn't work for me. So what you can do is to Change the query type to "Text " and execute your stored procedure here. e.g.
exec dbo.my_stored_proc

Microsoft SQL Server 2005 backup the database in *.sql

I work in a small company which is running M/S SQL Server 2005
Now our head office is asking me to give the whole database backup with the table schema in a single file of *.sql
please help me to backup my database in a *.sql including the table schema.
Thanks in advance.
Use SQL Server Management Studio
right click on your database and choose Generate scripts... and hit Next
choose Script entire database and all database objects and hit Next
choose Save to file and enter a path and a file name for your future sql script file. On the same screen choose Advanced and change the Types of data to script property value from Schema only to Schema and data. Hit OK. Hit Next.
and hit Next again.
You can download, install, and use SQL Server Management Studio that comes free with Microsoft® SQL Server® 2012 Express for that
I would go out and download Microsoft SQL Server Management Studio Express.
http://www.microsoft.com/en-us/download/details.aspx?id=8961
It is free. You will be able to connect to the database, drill down into Databases, right click and under Tasks, pick Backup Database. Make sure you pick full...CHoose Disk as the place you want to write it to and Execute...Look thru your options as well...
Hope this helps!
I’d go with the method peterm suggested but note that this also has flaws. Problem is that SSMS doesn’t order the scripts in correct execution order.
For example, it might happen that DDL for stored procedure P is before DDL for table T that is used in P.
All you need to do is to review your script and make sure there are no such cases. If there are you can try fixing this yourself or using some third party tool to generate script that is ordered correctly.

How to create multiple stored procedures from .sql files

I have about 100 stored procedures files that I want to add to a new database that I created. Is there any way I can just drop them in a folder to import them? When I tried that, like how you would with windows explorer, it just opened them all in query windows.
I am using SQL Server Management Studio.
Right now you did not respond to the question in the comments to make your question clearer, but I have these two suggestions
Assuming you already have a database that uses these procedures:
Right click the database in Management Studio and click on Task
Click on Generate Scripts
In the dialog that comes up, click next as you specify the right options
Select the checkbox for "Stored Procedures"
Select All the required stored procedures
Select option to generate script to a new window or file
You are done. Run you script on the other database
If you have access to Visual Studio
Create a new SQL Server Database project
Select the connection string of your new database
Create a stored procedure folder and add all the stored procedure files from your system to it
Right click the project and click Deploy/Publish
Hope you have the tables referenced in the stored procedures

Execute sql commands in Visual Studio server explorer?

How can I execute SQL commands in Visual Studio Server Explorer?
When I right click a sql directory (like tables), I get the options:
Add new table
Compare data
Execute query
But I want to do none of these, what I want is an empty screen where I can type my command, and execute it.
I don't want to use "Execute query" for writing commands, because it's for writing "queries", not all commands.
Alright, this is a pretty retarded solution to this problem but I guess it's good enough for me. I downloaded SQL Managment Studio, and installed it. It comes with a handy "Ssms.exe" that's hidden somewhere in program files with which you can manage your db.
From SQL Server point of view; a "command" and a query is the same thing. It is evaluated by the same code in the server.
A "command" is a SQL server DDL (Data Definition Language). A query is a SQL server DML (Data Manipulation Language). In a SQL server command batch use can issue both DDL and DML.
The "New Query" button which will give you the behavior you are expecting is available by adding the menu through View > Toolbars > Transact-SQL Editor

Stored Procedure to generate insert and create SQL for database

How can I move a db from one server to another (I only have access to the database with mylittleadmin). Like the title says, I guess the "easiest" way would be by generating SQL with a stored procedure.
I'm using SQL Server 2008 on both servers.
In the codeplex project Extreme T-SQL Script I have written T-SQL procedures to script the content of tables. I just abandoned its use myself in favor of ssms tools pack, but the later is no option for you.
When using these procedures in SSMS or VS the main problem is that Microsoft has limits on max column width and max length of output from Print-Statements.
I can't predict, which such limits exist when using mylittleadmin.
It depends on which datatypes and which varchar length you are using. Writing scripts that handle special needs is possible.
Further you need something to script the database objects first and it might be difficult to find something for that, as most people just use SSMS for this purpose. sp_helptext might help to script procedures.
In SSMS, you have the ability to copy or move a database from one instance of SQL Server to another. You can right-click on the database in SSMS, choose Tasks and then Copy Database...
Or, of course, you can simply backup the DB and restore on your target server.
(I have no idea what 'myLitleAdmin' is that you referred to)
You dont need to make a stored procedure. The easiest way to do it is by right click on your database -->task-->back up and create a backup.
after that you can restore your database on the other server.
If you have a license for myLittleAdmin then do as their web states. It says
"Purchasing a license gives you unlimited mail support.
Send your request at support#mylittletools.net"
Actually I found out that you could make a backup of the database in myLittleAdmin. The resulting .bak file was then emailed to me as a link.
Thanks for the comments though, voted up some of them :)