Task -Generate scripts
I have a database for an in devolpment application that i need to script entirely to create it a new to have changes follow to the test server so that the testers can do their thing. I started noticing recently that some of the relations were actually not
scripted. This causes me headaches because I dont want to have to recheck everything after words.
I am using SQL Server 2008 R2
Microsoft SQL Server Management Studio 10.50.4000.0
Microsoft Analysis Services Client Tools 10.50.4000.0
Microsoft Data Access Components (MDAC) 6.1.7601.17514
Microsoft MSXML 3.0 6.0
Microsoft Internet Explorer 9.0.8112.16421
Microsoft .NET Framework 2.0.50727.5483
Operating System 6.1.7601
Not terribly design related, but I would suggest trying SSDT (SQL Server Data Tools:
http://msdn.microsoft.com/en-us/data/tools.aspx, pretty sure it is free and they have a forum), or RedGate's Data Compare Tool (and there are others that you could probably find too, these are the
ones I have seen the most of).
Both will let you compare one db to another (or a set of scripts, or a project), and comparing a built db to an empty database will let you generate a script for everything in the database to upgrade an empty db to your schema.
Having a compare tool available is essential for developing scripts and building upgrade plans, if for no other reason than to let you make sure your scripts are doing what you expect.
Louis
Without good requirements, my advice is only guesses. Please don't hold it against me if my answer answers my interpretation of your questions.
Similar Messages
-
How to get feedback messages for schema creation script created by Tasks- Generate Script
I am using sql server 2008 R2. I created a script file by using Tasks->Generate Scripts. I
selected option so only create statements are generated for all objects – tables, indexes, views, functions etc in the database.
Then when I used this generated script to create objects in another database in SSMS, it created the objects but did
not give me any feed back, i.e., table created, view created etc. I thought my script did not run , but when I refreshed left panel
of SSMS and I can see all created objects.. So question is what is needed to get
feedback when sql statements are run..You need to add the PRINT statements yourself for that. The wizard will not do it for you.
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Generate Scripts in SQL Server 2008 R2 producing Error "Item has already been added.:
I am trying to run a Generate Scripts Task on a Database to generate a script for every object in the DB including tables, SPs, UDFs, FKs, PKs, with the settings for Schema Only, Script Drop and Create, Script "if not Exists", use database,
and Object level permissions.
I have used generate scripts before to generate this database about 5 months ago and every thing worked fine.
Today I first tried to generate it out on a server where I only have "db_Owner" for several databases. This failed with the error.
Microsoft.SqlServer.Management.Smo.FailedOperationException: Discover dependencies failed. ---> System.ArgumentException: Item has already been added. Key in dictionary: 'Server[@Name='DLINHD007557\SQL_2008R2_64']/Database[@Name='VFS_ProcurementTracking']/UnresolvedEntity[@Name='prc_ContractFatInfo']' Key being added: 'Server[@Name='DLINHD007557\SQL_2008R2_64']/Database[@Name='VFS_ProcurementTracking']/UnresolvedEntity[@Name='prc_ContractFatInfo']' at System.Collections.SortedList.Add(Object key, Object value) at Microsoft.SqlServer.Management.Smo.DependencyTree..ctor(Urn[] urns, DependencyChainCollection dependencies, Boolean fParents, Server server)
So I tried tto do this on a local version of the database where I have sa rights. Same error.
Can someone advise me on what is going on here and how do I fix it?
Edward R. Joell MCSD MCDBAHow do you generate the script via SMO?
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Timout expired error is coming while generating script in sqlserver
i try to backup my database from hosted server. so i generating scripts with data via wizard. after executing all objects ,one error is coming like 'timeout expired'. and i try to restore this script file in my local database. but many tables,stored procedures,functions
are missing. please help me how to take complete scripts correctly?Hello,
It’s a long running task and the default timeout is 30 seconds, The database seems to be too big for the generating script with data
feature.
Try to script big tables one by one if you still want to use that feature or use backup/restore as mentioned above.
Hope this helps.
Regards,
Alberto Morillo
SQLCoffee.com -
Generate scirpt is generating script twoice.
hi,
(when we right click on datababase -> task->generatescript sql server 2008r2)
it creates a script.
i used the "generate script" wizard to generate script , but noticed that, it is generating a script twoice.
/****** Object: ForeignKey [FK_Table_4_Table_3] Script Date: 09/01/2014 10:29:08 ******/
ALTER TABLE [dbo].[Table_4] DROP CONSTRAINT [FK_Table_4_Table_3]
GO
/****** Object: Table [dbo].[Table_4] Script Date: 09/01/2014 10:29:08 ******/
ALTER TABLE [dbo].[Table_4] DROP CONSTRAINT [FK_Table_4_Table_3]
GO
DROP TABLE [dbo].[Table_4]
GO
/****** Object: Table [dbo].[Table_3] Script Date: 09/01/2014 10:29:08 ******/
DROP TABLE [dbo].[Table_3]
GO
/****** Object: Table [dbo].[Table_3] Script Date: 09/01/2014 10:29:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Table_3](
[ABC] [int] NOT NULL,
[ABC1] [int] NULL,
CONSTRAINT [PK_Table_3] PRIMARY KEY CLUSTERED
[ABC] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Table_4] Script Date: 09/01/2014 10:29:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Table_4](
[ABC] [int] NOT NULL,
[ABC1] [int] NOT NULL,
[ABC2] [int] NULL,
CONSTRAINT [PK_Table_4] PRIMARY KEY CLUSTERED
[ABC] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: ForeignKey [FK_Table_4_Table_3] Script Date: 09/01/2014 10:29:08 ******/
ALTER TABLE [dbo].[Table_4] WITH CHECK ADD CONSTRAINT [FK_Table_4_Table_3] FOREIGN KEY([ABC1])
REFERENCES [dbo].[Table_3] ([ABC])
GO
ALTER TABLE [dbo].[Table_4] CHECK CONSTRAINT [FK_Table_4_Table_3]
GO
please notice stmt first and second is duplicate
yours sincerleyActually the script is not actually 'doubled' but dropping the same constraint twice.
Seems to me it's a bug since they should be aggregated.
Trying that with SQL 2014 works just fine. -
Error while runnig OIM task purging script OIM_TasksArch.sh
Error while runnig OIM task purging script OIM_TasksArch.sh
## Enter date in YYYYMMDD format
(All the task data for users which have been disabled/deleted on or before the entered date would be archived) :
## All the task data for users which have been disabled/deleted on or before TODAY's date would be archived,
Do you want to continue [y,Y,n,N]? :
y
Calculating the number of records that would be archived,
this may take some time, please wait...
ERROR ==> An error has occurred during the process
Please check logs created at /export/home/oracle/Purging_Task/Err_Arch_tasks_2012_11_05_16_51_22.log and try again
./OIM_TasksArch.sh: test: argument expected
bash-3.00$ cat /export/home/oracle/Purging_Task/Err_Arch_tasks_2012_11_05_16_51_22.log
-- Task Archival Execution Status
Task Data Archival Summary
ORA-00942: table or view does not existIn this link you resolved this issue by giving all privileges to DEV_OIM...
Re: Getting error while running OIM in built purging script OIM_ReconArch.sh
Now if again this ORA-00942: table or view does not exist is coming, possibility is that there is no issue regarding privileges as you already have given all privileges to DEV_OIM...
Anyway try again giving full permissions to it just in case for some reasons permissions might have reset...
Now the only option is to study OIM_TasksArch.sh and figure out which tables or view it wants to refer to and is not available to it..
*./OIM_TasksArch.sh: test: argument expected*
The above line means that this sh file needs some arguments... Please study a bit more to figure out those arguments.. It will work...
*23.2.1 Understanding the Task Archival Utility*
http://docs.oracle.com/cd/E21764_01/doc.1111/e14308/archival_utilities.htm#OMADM3033
Following Parameters i.e. Arguments are needed
# File : OIM_TasksArch.sh
# Purpose : To archive data from active task tables to archival task
# tables and to delete data from active task tables.
# Arguments : 1 --> Location of the Oracle Home(ORACLE_HOME)
# 2 --> Oracle Identity Manager Database Name
# 3 --> Oracle Identity Manager Database User Name
# 4 --> Password for the Oracle Identity Manager Database User -
Question about DBCA generate script o create RAC database 2 node cluster
Question about creating two node RAC database 11g after installing and configuration 11g clusterware. I've used DBCA to generate script to create a rac database. I've set
environment variable ORACLE_SID=RAC and the creating script creates instance of RAC1 and RAC2. My understanding is that each node will represent a node, however there should only be one database with a name of 'RAC'. Please adviseYou are getting your terminology mixed up.
You only have one database. Take a look, there are one set of datafiles on shared storage.
You have 2 instances which are accessing one database.
Database name is RAC. Instance names are RAC1, RAC2, etc, etc.
Also, if you look at the listener configuration and if your tnsnames is setup properly then connecting to RAC will connect you to either one of the instances wheras connecting to RAC1 will connect you to that instance. -
Runtime-Error after deploying a mapping with the generated script
For example a very easy scenario:
1. Create a table and a view in a DB-schema, witch ist registered as WB-target-schema with the following scripts:
create view v1(c1) as select 'a' c1 from dual;
create table t1(c1 varchar2(1));
2. Import the table and the view into a OWB-module
3. Create a mapping ‘m1’
4. Drag and drop view and table into the mapping
5. Draw an arrow from the view-column to the table-column
6. Save and close the mapping
7. Mark the mapping in the ‘Design Center’ and klick the ‘Generate’-Button
8. Save the generated script ‘M1.pls’ to file
9. Run the script in SQL*Plus, connected with the target-schema (without using the Control Center Manager)
=> very easy right now ;-)
10. Start the mapping with the following script will produce the following error
SQL> declare
2 v_status varchar2(100);
3 begin
4 m1.main(v_status);
5 end;
6 /
declare
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "OWB_OWN.WB_RT_MAPAUDIT_UTIL", line 1027
ORA-06512: at "SCOTT.M1", line 2048
ORA-06512: at line 4
If i delete or comment the four WB_RT_MAPAUDIT_UTIL-calls - it work´s fine!
But is this a good advise?
What exactly does the wrapped package ‘WB_RT_MAPAUDIT_UTIL do?
Thanks
jwehnerI just ran into the same problem myself. I used the same technique of saving the generated OWB script to file and then compiling it through sqlplus. When I used the "Deploy" option for the mapping, then the problem went away. So when OWB is deploying the code it seems to be setting something internally that doesn't get set when you simple compile the PL/SQL. I don't know of any workaround to this. I will need it eventually, since I don't want to use the UI to deploy to various test environments and production. Maybe the built-in scripting language is the way to go.
-
SQL Developer 3.0.04 generated scripts not compatible with Oracle 10g (XE)
HI,
I tried to do an export from one XE database (still 10g) to another XE database. (also 10g).
I tried to do a database copy as well as a separate export and import (by loading the file and running as a script).
Neither of them work without modifying the files as it seems that SQL Developer generates scripts that are only compatible with Oracle 11g.
- Create table contains "segment creation automatic"
- Storage clauses contain parts that are not compatible with 10g
I ran through the wizard several times but neither can I find an option to choose for compatibility with earlier versions of Oracle.
Checked the preferences screen as well.
Is this a well hidden option or is it not possible to make this work for 10g.
Extra : found workaround by removing the storage clause to the export. Is there another way that does not force me to remove the storage clause?
Edited by: kcaluwae on 24-jun-2011 6:03I'm sure this is far from the supported way to fix this but, seeing that it's apparently an issue with the classpath or something in it, I hacked <sqldeveloper_install>\sqldeveloper\bin\sqldeveloper.bat and added [ORACLE_HOME]\jdbc\lib\ojdbc6.jar to the classpath. At least that gets me started with 3.0 and lets me create TNS connections.
I'd really appreciate a better solution, if any of you kind folks knows of something.
Thanks,
Kelly -
Sql developer database diff - generate script not working
Using SQL devleloper 2.1. Database diff generate script gives errors making it completely non-usable
ORA-31600: invalid input value 0 for parameter SEGMENT_ATTRIBUTES in function SET_TRANSFORM_PARAM
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
ORA-06512: at "SYS.DBMS_METADATA_INT", line 8150
ORA-06512: at "SYS.DBMS_METADATA_INT", line 9270
ORA-06512: at "SYS.DBMS_METADATA", line 4757
ORA-06512: at line 1
and
Illegal Lock State: executeOracleQuery requires connection lock to be held. oracle.dbtools.raptor.diff.oracle.table.DiffTableRefConstraints.setup(DiffTableRefConstraints.java:215) called oracle.dbtools.db.DBUtil.executeQuery(DBUtil.java:681) without it
I do get the differences visually (yes, I am bugged that constraints are not smart enough to compare on content of the constraint....problem when the contstraint names are sys-nnnnnn generated). Just cannot create the script.
Any ideas to solve this issue? Thanks in advance, KellyCan reproduce same issue in 11gR1.. DIFF works fine in 10gR2.
I noticed that 10gR2 allows something like:
DBMS_METADATA.SET_TRANSFORM_PARAM(th,'SEGMENT_ATTRIBUTES',0);
and 11GR2 returns error similar to error SQLNAVIGATOR returns while running diff:
DBMS_METADATA.SET_TRANSFORM_PARAM(th,'SEGMENT_ATTRIBUTES',0);
end;
Error report:
ORA-31600: invalid input value 0 for parameter SEGMENT_ATTRIBUTES in function SET_TRANSFORM_PARAM
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
ORA-06512: at "SYS.DBMS_METADATA_INT", line 8424
ORA-06512: at "SYS.DBMS_METADATA_INT", line 9484
ORA-06512: at "SYS.DBMS_METADATA", line 3950
Its safe to assume that this is SQLDEVELOPER bug. Hope it will be addressed sometime.
Edited by: user5420304 on Jun 15, 2010 10:29 AM -
To generate Script of procedures/functions and packages with grants
Hi
is there wome way for to generate Source Code Script of the some functions, procedures and Packages in file
I must to generate Script withall grants
TiaDatapump export with Content=Metadata_only.
Use SQLFILE option to generate the Schema DDL which
includes
tables,indexes,grants,stats,procedures,triggers,views
etc...Sorry, I'm using 10g , but I don't know to use DataPump, is there other method ?
Thanks -
Task notification script & smart folks
Has anybody smarter than me done anything cool with the Task Notification Script at
/Library/Application Support/Apple/Remote Desktop/Notify
I have it sending me notification of success and failure. It would be nice if it included info on:
• reasons for failure
• successes by machine name or IP addresss
• failures by machine name or IP address
• info on pending tasks
I'm sure you can think of additional items.
b.The sample Notify script in /Library/Application Support/Apple/Remote Desktop shows pretty much what you can expect to achieve though the use of the task notification script.
It gets passed 2 pieces of data. The task (class) and the final state of the task. The sample script sends an email to a pre-configured user, but you could easily create a version that would append the text to a file, or write out a new file using either defaults or PListBuddy. -
Generate Script to Project doesn't generate CREATE OR REPLACE objects
Hi,
I am using VS2008 SP1 with ODT. If I go to ServerExplorer to connected database and run Generate Script to Project the object (Package, package body , function ...) is always
created to the project as CREATE function myfunction.
I need to have it in this way CREATE OR REPLACE ... to run it against database.
Is there any way to configure it somehow ?
Thanks in advance
JörgHi there is currently no way to automatically generate CREATE or REPLACE instead of just CREATE. You'll need to manually modify the file to add the "or REPLACE" to the stmt or add a DROP line just before the CREATE stmt.
-
Generate script for filling table
Hi all,
I've got table at test Oracle server table1 with columns ID, BTYPE, MYDESCRIPTION. Rows of this table have been inserted manually. Now my need is to write script for creating table (structure + data). I think about writing something like
CREATE TABLE table 1
AS
SELECT 1 AS ID, 'TYPE1' AS BTYPE, 'SOME TEXT' AS MYDESCRIPTION
UNION ALL
SELECT 2 AS ID, 'TYPE2' AS BTYPE, 'SOME TEXT 2' AS MYDESCRIPTION
But rows are too many to type... Could you please suggest some way of generating script for creating table at working server using existing table at test server? The problem is I don't have an access to working server.
Thanks ahead.Use the view user_tab_cols
say
declare
cursor c1 is
select 'e_'||column_name ||' '||data_type||' ('||data_length||') ' col
from user_tab_cols
where table_name = 'DEPARTMENTS'
union
select 'd_'||column_name ||' '||data_type||' ('||data_length||') ' col
from user_tab_cols
where table_name = 'EMPLOYEES';
v1 varchar2(500);
begin
v1 := 'create table new_tabl (';
for i in c1 loop
v1 := v1||i.col||',';
end loop;
v1 := substr(v1,1,length(v1)-1);
dbms_output.put_line(v1||')');
end;
/i am using employees and departments table of hr schema.
now as both the tables have some column column so i have used e for employees and d for departments
just do one thing remove the length for date data type in o/p i dont know why it is not working.
this will give you structure for data use any sql stmt
Edited by: 810345 on Jun 9, 2011 9:58 PM -
How to control Task generated from sales stage?
HI,
I have some specific task that are generated when a user select a sales stage
Is it possible to find a way to control the status of the task generated to be sure that all the task are done before the user can select the next sales stage?
Regards,Hi Santosh,
Thanks for your answer but can you detail a little bite how you can check status of all task related to an opportunity using workflow rule?
How can you block the sales stage in order to avoid user to pass next sales stage if all the tasks are not done?
Regards,
Maybe you are looking for
-
Wireless VoIP roaming - getting an 802.11g phone to roam with CCX / CCKM
Hello, Our group is facing a pretty difficult issue at the moment, we are trying to deploy a wireless Avaya VoIP phone at one of our sites in Australia. The site in question is located in Western Australia, which is on the other side of the continent
-
Incorrect time displayed in Lost mode email notifications from iCloud
Lost mode email notifications from iCloud displays California time, even though my iCloud setting is in a different time zone. Can this be changed? How?
-
How to add arraycollection to the httpservice's url property??
hi all.., i want to add arraycollection data to the httpservice url property... how can i add it can anybody explain with bit syntax??????// thank u... vijay kotha
-
Lazy downloading broken for updated jar-files?
Hello, Using webstart-6.0 + jar-index + download="lazy" works great - jar files are downloaded on demand when they are really needed. However when updating all jar-files, the files that have been downloaded lazily and cached before are downloaded aga
-
IOS8: Gap for Delete Email Message
Is anybody else seeing this (below)? If so, I'd like to encourage you to report it as a bug on http://www.apple.com/feedback/iphone.html. I have done so, but the more people who report it the better. Under iOS 8 on my iPhone (I can't recall seeing