modifying SP in sql server 2008 by using SQL query - sql-server-2008

We are promoting a lot of old stored procedures to production but the are referencing a development box. Is there any easy way to search all the procedures and update them? I tried updateing the defintion field in the sys.sql_modules, and also tried updating the syscomments.text but was unable to. Here is an example of what I am trying to do.
in a stored proc we have the following select * from vmdproduction.test.dbo.table1, I would like to rename the vmdproduction to production in all cases across all stored procedures.
Thanks

This is how I would do it... In Management Studio, right-click your database, select Tasks, Generate Scripts. Go through the wizard and be sure to include all stored procedures and to "Script DROP and CREATE" (under advanced options). This will generate a script file which will drop and recreate all the procedures. You can then do a find and replace before you run the script. Be sure to backup the db before running it though!

Using SQL Server Management Studio
To modify a procedure in Management Studio
1.In Object Explorer, connect to an instance of Database Engine and then expand that instance.
2.Expand 'Databases', expand the database in which the procedure belongs, and then expand 'Programmability'.
3.Expand 'Stored Procedures', right-click the procedure to modify, and then click 'Modify'.
4.Modify the text of the stored procedure.
5.To test the syntax, on the 'Query' menu, click 'Parse'.
6.To save the modifications to the procedure definition, on the 'Query' menu, click 'Execute'.
7.To save the updated procedure definition as a Transact-SQL script, on the 'File' menu, click 'Save As'. Accept the file name or replace it with a new name, and then click 'Save'.

Related

How can execute flexible search on japers reports?

I'm beginner in hybris. I need to create a jasper reports, using flexible search and mysql server. But I can only use the sql query statement without flexible search in report file (Jrxml source file (.jrxml)).
How can I using the flexible search with mysql?
Are you following the guide provided in Hybris Help for building a custom report? It can be found at https://help.hybris.com/6.3.0/hcd/8b6e40ee86691014b99eda29aebc9d84.html
In the interest of having a source of information in case the link ever becomes dead:
Go to ${HYBRIS_DIR}/hybris/bin/platform
setantenv.bat for Windows or . ./setantenv.sh for Unix/Linux
Go to ${HYBRIS_DIR}/hybris/bin/ext-platform-optional/virtualjdbc
Run the ant command ant dist
Go to ${HYBRIS_DIR}/hybris/temp/hybris/virtualjdbc. You should have two files that have been generated here, hybris-virtualjdbc.jar and vjdbc.jar
You now need to copy these two files to ${HYBRIS_DIR}/hybris/bin/ext-platform-optional/virtualjdbc/lib
Download the Jaspersoft Studio Tool at http://community.jaspersoft.com/project/jaspersoft-studio
Install and Open Jaspersoft Studio
Go to Tools > Options > iReport > Classpath
Click Add JAR twice, each time selecting one of the newly copied JAR files (hybris-virtualjdbc.jar and vjdbc.jar)
Click OK
You now need to setup the Data Source, to do this:
Click on the Report Datasource icon ()
In the newly opened window, click New
Select Database JDBC Connection and click Next
On the next screen you may provide any name for your JDBC Connection
In the JDBC Driver field, make sure you type de.hybris.vjdbc.VirtualDriver
In the JDBC URL field, make sure you type jdbc:hybris:sql:http:///virtualjdbc/service, where is the location of your application server (e.g. https://localhost:9002). Remember this will change with each environment!
Provide a Hybris User for the Username and Password. It may be worth using the admin user to begin with, but make sure you lock it down at a later stage to a user with less access, such as vjdbcReportsUser
Test the connection. Remember you will need the server up and running to be able to use vjdbc
From here onwards, you should be able to create a report using Flexible Search style syntax!

Set up a Datasource for Tabular Models in SQL Server

I want to go through this tutorial. Unfortunately the author has already set up the datasources
and does not explain how to set them up. First off I installed an separate SSAS Instance in my sql server 2014. Then I tried to add a .mdf file via "Attach" but get the Error "AdventureWorks.detach_log could not be found in the folder". So according to this SO solution I tried this command:
CREATE DATABASE YAFnet ON (FILENAME = N'C:\sql_data\YAFnet.mdf')
FOR ATTACH_REBUILD_LOG;
within my SSAS instance query editor but it looks like the query is not a proper one since it is mdx.
Anyone who can help me to get a datasource (adventureworks dw) for my tabular model so I can follow the tutorial?
I would download the tabular backup from AW samples and recover the .abf file

Migration from postgresql to Mysql

Hello there i'm really newbie to SQL and i have a problem to create a dump file properly, I have an assignment and i don't really have no idea what's wrong, can anyone help me to migrate it? According to phpmyadmin the error is somewhere in this part.
CREATE TABLE DEPT (
DEPTNO NUMERIC(2) NOT NULL,
DNAME CHAR(14),
LOC CHAR(13),
CONSTRAINT DEPT_PRIMARY_KEY PRIMARY KEY (DEPTNO));
Why not use an ETL Tool? you dont have to worry about dumps or stuff like that. You just need to know the connection credentials and thats it. I personally use Pentaho ( it's open source ).
Download Pentaho ETL from http://kettle.pentaho.org/
Unzip and run Pentaho (using .bat file spoon.bat)
Create a new Job:
Create DB connection for source data base (PostgreSQL) - using menu: Tools→Wizard→Create DataBase Connection (F3)
Create DB connection for destination data base (Mysql) - using technique described above.
Run the Wizard: Tools → Wizard → Copy Tables (Ctrl-F10).
Select source (left dialog panel), and destination (left dialog panel). Click Finish.
The Job will be generated - Run the job.
Thats it! If you need any help let me know.
I've tried to open the tools via pgadmin3 but is something like frozen, I reboot my pc and still have no access to the "tools"

mySQL ,sql file netbeans

How do I execute a .sql file using mysql and netbeans.
I am doing a course that requires me to interact with an .sql file that they have provided but the good guys at the Fitzwilliam institute haven't deemed it fit to explain how to use this file.
If can tell me that would be great.
I have already set up the basic database using netbeans and mySql.
Thank you
Ok, if you have created a connection to your MySql db, then things are pretty forward. Go to 'Services' tab, expand the Database options. Right click the connection you have created. Click 'Connect' to connect to the db. And then right click your connection and click 'Execute Command...'.
Write the command in the editor, and click the 'Run Sql' (Ctrl+Shift+E)
if the sql file is too large, netbeans cannot open it. In this case you can use the tool ij (link) which comes with Derby:
Start ij commandline tool and then do something like this:
ij> connect 'jdbc:derby:MyDbTest;create=true' user 'peter' password 'parker';
ij> run 'sqlscript.sql';
Running an SQL Script
Another way to manage table data in NetBeans IDE is by running an external SQL script directly in the IDE. If you have created an SQL script elsewhere, you can simply open it in NetBeans IDE and run it in the SQL Editor.
For demonstrative purposes, download ifpwafcad.sql and save it to a location on your computer. This script creates two tables similar to what you just created above (Counselor and Subject), and immediately populates them with data.
Because the script overwrites these tables if they already exist, delete the Counselor and Subject tables now so it becomes obvious that new tables are being created when the script is run. To delete tables:
Right-click the Counselor and Subject table nodes in the Database Explorer and choose Delete.
Click Yes in the Confirm Object Deletion dialog box. Note that the dialog box lists the tables that will be deleted.
When you click Yes in the Confirm Object Deletion dialog box, the table nodes are automatically removed from the Database Explorer.
To run the SQL script on MyNewDatabase:
Choose File > Open File from the IDE's main menu. In the file browser navigate to the location where you previously saved ifpwafcad.sql and click Open. The script automatically opens in the SQL Editor.
Make sure your connection to MyNewDatabase is selected from the Connection drop-down box in the toolbar at the top of the Editor.
Connection drop-down box in the SQL Editor toolbar
Click the Run SQL (run SQL button) button in the SQL Editor's task bar. The script is executed against the selected database, and any feedback is generated in the Output window.
To verify changes, right-click the MyNewDatabase connection node in the Runtime window and choose Refresh.
The Refresh option updates the Database Explorer's UI component to the current status of the specified database. Note that the two new tables from the SQL script now display as a table nodes under MyNewDatabase in the Database Explorer.
Choose View Data from the right-click menu of a selected table node to see the data contained in the new tables. In this manner, you can compare the tabular data with the data contained in the SQL script to see that they match.

Generate Scripts to copy views

I wish to use the Generate Scripts option in SSMS 2008 to copy views on a DEV db to LIVE db.
I set advanced permissions for "Include IF NOT EXISTS = True" & "Script DROP and CREATE = Script DROP and CREATE".
However, when I run this on my LIVE db it complains that:
Msg 208, Level 16, State 1, Procedure vw_XXXXXInviteEventDaysA_DELETE, Line 4
Invalid object name 'dbo.vw_XXXXXInviteEventDays'.
...I get a lot of occurrences of this.
Would I be right in thinking this error relates to the view replying on another view that is waiting later in script to be created? If so, how do I get around this?
Thanks Paul
You can use Visual Studio 2010 Database Project.
Via the feature "Schema Compare", you can compare 2 databases and generate deployment script if only you have access to both databases.