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.
Related
Do not seem to be able to find any place in the portal or Report Builder where I can actually edit the connect string & creds.
Report Manager shows the XML, but that really is it.
Disk files (from the looks of it) are no longer present in high versions (using SQL 2016/2017).
Is there a known location anywhere in GUI, or maybe direct edits in the SQL Server repository?
I can't even delete a shared source anymore, only view or test the connection.
If anybody could post a screenshot, it'll be highly appreciated.
EDIT: Just found out - when I create a new Data Source, it's editable; the imported data sources are not.
There are two ways of doing this. You can set the 'overwrite datasource' option in the project properties.
Or, you can got to the report portal , show hidden items in the view menu and there is a folder called "data sources". Open this and you will see all data sources, from there you can edit and save changes. All reports that use that datasource will be affected.
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
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.
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'.
I have created a new Schema in a database called Contexts. Now when I want to write a query, Management Studio doesn't recognize the tables that belong to the new Schema. It says: 'Invalid object name Contexts.ContextLibraries'...
Transact-SQL:
INSERT INTO [Contexts].[ContextLibraries] (ChannelId, [IsSystem])
VALUES (#ChannelId, 1)
When I try the same thing on my local database, it does work...
Any ideas?
I did try to change the Default schema for the user from dbo to Contexts but this doesn't work. Also checked Contexts in Schemas owned by this user without success.
Update: Apparently the sql query does work but the editor gives a fault saying the object is invalid.
Try to refresh local cache of Management Studio:
Management Studio Menu >> Edit >> IntelliSense >> Refresh Local Cache
or use shortcut:
CTRL + SHIFT + R
I always forget that it's there.
You may need to refresh SSMS: if raw SQL works.
Frankly, the easiest way is to close object explorer on the server and re-open. The SQL Server client tools have a problem with caching back into the Jurassic period...