Generating SQL Script for Existing Tables and DBs
Hello,
is it possible to generate automatically a SQL-Script from an existing table or oracle database ?
I want to export an existing table from an Oracle DB (g11) if its possible with the data.
Perhaps somebody could me explain how to to do this.
I am using the "SQL Developer 2.1" and the "enterprise manager konsole".
I'm a rookie in using this tools.
Thank you for any informations.
N. Wylutzki
If you want to export data, you should use the export utility. This is documented:
http://tinyurl.com/23b7on
Similar Messages
-
Generating Insert Scripts for multiple tables
Hi,
I have 6 tables TABLA,TABLB,TABLC,TABLED,TABLEE,TABLEF
I want to generate Insert Scripts for the above 6 tables.
Is there any mechanism to do so so that i can generate the .sql files for the above 6 tables to another schema?
Any help will be needful for me.Hi,
May the below given function script help you...
CREATE OR REPLACE FUNCTION get_insert_script (v_table_name VARCHAR2)
RETURN VARCHAR2
AS
b_found BOOLEAN := FALSE;
v_tempa VARCHAR2 (8000);
v_tempb VARCHAR2 (8000);
v_tempc VARCHAR2 (255);
BEGIN
FOR tab_rec IN (SELECT table_name
FROM all_tables
WHERE table_name = UPPER (v_table_name))
LOOP
b_found := TRUE;
v_tempa := 'select ''insert into ' || tab_rec.table_name || ' (';
FOR col_rec IN (SELECT *
FROM cols
WHERE table_name = tab_rec.table_name
ORDER BY column_id)
LOOP
IF col_rec.column_id = 1
THEN
v_tempa := v_tempa || '''||chr(10)||''';
ELSE
v_tempa := v_tempa || ',''||chr(10)||''';
v_tempb := v_tempb || ',''||chr(10)||''';
END IF;
v_tempa := v_tempa || col_rec.column_name;
IF INSTR (col_rec.data_type, 'CHAR') > 0
THEN
v_tempc := '''''''''||' || col_rec.column_name || '||''''''''';
ELSIF INSTR (col_rec.data_type, 'DATE') > 0
THEN
v_tempc :=
'''to_date(''''''||to_char('
|| col_rec.column_name
|| ',''mm/dd/yyyy hh24:mi'')||'''''',''''mm/dd/yyyy hh24:mi'''')''';
ELSE
v_tempc := col_rec.column_name;
END IF;
v_tempb :=
v_tempb
|| '''||decode('
|| col_rec.column_name
|| ',Null,''Null'','
|| v_tempc
|| ')||''';
END LOOP;
v_tempa :=
v_tempa
|| ') values ('
|| v_tempb
|| ');'' from '
|| tab_rec.table_name
|| ';';
END LOOP;
IF NOT b_found
THEN
v_tempa := '- Table ' || v_table_name || ' not found';
ELSE
v_tempa := v_tempa || CHR (10) || 'select ''- commit;'' from dual;';
END IF;
RETURN v_tempa;
END;(copied and pasted from a commercial site)
*009*
Edited by: 009 on Jan 14, 2010 10:43 PM
(Function after debug) -
How to generate sql script based on table structure
I want to generate a sql script based on a table structure.
For example:
if the table is:
cid id c_value
1 1 zz
2 1 yy
3 2 zz
4 2 xx
5 3 ss
6 3 tt
The expected output is:
WITH
CHILD_tab as (
SELECT 1 cid, 1 id,'zz' c_value from dual union all
SELECT 2 cid, 1 id,'yy' c_value from dual union all
SELECT 3 cid, 2 id,'zz' c_value from dual union all
SELECT 4 cid, 2 id,'xx' c_value from dual union all
SELECT 5 cid, 3 id,'ss' c_value from dual union all
SELECT 6 cid, 3 id,'tt' c_value from dual )
Release 11.1.0.7.0I'm doing a lot of XML these days (too much perhaps) so here's a solution involving XQuery.
We pass a query string and it outputs a CLOB containing the WITH clause :
SELECT DBMS_XMLGEN.Convert(
XMLQuery(
q'[concat(
"WITH t AS (
string-join(
for $i in /ROWSET/ROW
return concat( " SELECT ",
string-join($i/*/concat("'",ora:replace(text(),"'","''"),"' ",local-name()),", "),
" FROM dual" ),
" UNION ALL
passing dbms_xmlgen.getXMLType('SELECT * FROM scott.emp')
returning content
).getClobVal(), 1) AS WITH_CLAUSE
FROM dual;
WITH_CLAUSE
WITH t AS (
SELECT '7369' EMPNO, 'SMITH' ENAME, 'CLERK' JOB, '7902' MGR, '17/12/80' HIREDATE, '800' SAL, '20' DEPTNO FROM dual UNION ALL
SELECT '7499' EMPNO, 'ALLEN' ENAME, 'SALESMAN' JOB, '7698' MGR, '20/02/81' HIREDATE, '1600' SAL, '300' COMM, '30' DEPTNO FROM dual UNION ALL
SELECT '7521' EMPNO, 'WARD' ENAME, 'SALESMAN' JOB, '7698' MGR, '22/02/81' HIREDATE, '1250' SAL, '500' COMM, '30' DEPTNO FROM dual UNION ALL
SELECT '7566' EMPNO, 'JONES' ENAME, 'MANAGER' JOB, '7839' MGR, '02/04/81' HIREDATE, '2975' SAL, '20' DEPTNO FROM dual UNION ALL
SELECT '7654' EMPNO, 'MARTIN' ENAME, 'SALESMAN' JOB, '7698' MGR, '28/09/81' HIREDATE, '1250' SAL, '1400' COMM, '30' DEPTNO FROM dual UNION ALL
SELECT '7698' EMPNO, 'BLAKE' ENAME, 'MANAGER' JOB, '7839' MGR, '01/05/81' HIREDATE, '2850' SAL, '30' DEPTNO FROM dual UNION ALL
SELECT '7782' EMPNO, 'CLARK' ENAME, 'MANAGER' JOB, '7839' MGR, '09/06/81' HIREDATE, '2450' SAL, '10' DEPTNO FROM dual UNION ALL
SELECT '7788' EMPNO, 'SCOTT' ENAME, 'ANALYST' JOB, '7566' MGR, '19/04/87' HIREDATE, '3000' SAL, '20' DEPTNO FROM dual UNION ALL
SELECT '7839' EMPNO, 'KING' ENAME, 'PRESIDENT' JOB, '17/11/81' HIREDATE, '5000' SAL, '10' DEPTNO FROM dual UNION ALL
SELECT '7844' EMPNO, 'TURNER' ENAME, 'SALESMAN' JOB, '7698' MGR, '08/09/81' HIREDATE, '1500' SAL, '0' COMM, '30' DEPTNO FROM dual UNION ALL
SELECT '7876' EMPNO, 'ADAMS' ENAME, 'CLERK' JOB, '7788' MGR, '23/05/87' HIREDATE, '1100' SAL, '20' DEPTNO FROM dual UNION ALL
SELECT '7900' EMPNO, 'JAMES' ENAME, 'CLERK' JOB, '7698' MGR, '03/12/81' HIREDATE, '950' SAL, '30' DEPTNO FROM dual UNION ALL
SELECT '7902' EMPNO, 'FORD' ENAME, 'ANALYST' JOB, '7566' MGR, '03/12/81' HIREDATE, '3000' SAL, '20' DEPTNO FROM dual UNION ALL
SELECT '7934' EMPNO, 'MILLER' ENAME, 'CLERK' JOB, '7782' MGR, '23/01/82' HIREDATE, '1300' SAL, '10' DEPTNO FROM dual
)It may be useful for small data sets only because we quickly hit ORA-01706. -
Generating .sql script for all objects of a User/Schema
Hi All,
What are the ways in which I can generate scripts for a full USER (all objects) with dependencies. (by dependencies I mean for example that PK be created first before creating FK).
We can export the full schema using (exp rows=n) but this will generate a .dmp file. I want a .sql file which can be run on any other machine (from SQL> prompt) so that user and all objects are created (without the need to use "imp").
Thanks
-AKJBut the easiest way to do this would be to do an export with rows=N and then an import.
You coule do an export and then let run the import utility with indexfile=<you_name_it>.sql and this way you'll get a file with all statements included (but table definition commented out).
Or you do it yourself (DIY-method), where you have to select all your relevant objects and their dependencies. -
SQL script for exporting table
Could anyone please help me with SQL (plain SQL, not PL/SQL) for writing the data from a table into a .csv file?
I need to run it on SQL developer. Can't use spool because it works only on SQL*PLus
Edited by: user10403078 on Oct 15, 2008 2:24 AMBut I want the SQL script to create a CSV file, because it should write the data from the tables into a CSV file, and proceed to delete it from the tables, every time the SQL script is run. I can't manually click and save.
-
SQL query for join table and multiple values
Trying to join two tables , Emphours and EmpStatus to get
result which gives each emplyees hour
worked each day
in past say 1 year in what status. I need result similar to table 3 , Hours Can also be grouped per week
all I need Is Each employees hours in each week and his status and position at that time if possible
any help will be highly appreciated. Thank you
note: payday is every other Friday- week runs from Saturday through Friday
EmpStatus Table tracks when employees status changed
EmpHours
employee
workday
payday
hours
position
101
1/1/2014
1/3/2014
8
assistant
101
1/3/2014
1/3/2014
8
assistant
101
1/4/2014
1/17/2014
8
assistant
101
1/5/2014
1/17/2014
8
assistant
101
1/7/2014
1/17/2014
8
assistant
101
1/8/2014
1/17/2014
8
assistant
101
1/9/2014
1/17/2014
8
assistant
101
1/11/2014
1/17/2014
8
assistant
101
1/13/2014
1/17/2014
8
assistant
101
1/14/2014
1/17/2014
8
assistant
101
1/18/2014
2/14/2014
8
assistant
102
1/1/2014
1/3/2014
7
manager
102
1/25/2014
1/31/2014
7
manager
102
1/26/2014
1/31/2014
7
manager
102
1/28/2014
1/31/2014
7
manager
102
1/31/2014
1/31/2014
7
manager
103
1/1/2014
1/3/2014
5
intern
103
1/31/2014
1/31/2014
6
intern
104
1/14/2014
1/17/2014
5
supervisor
104
1/30/2014
1/31/2014
6
supervisor
EmpStatus
employee
start_date
status
101
1/1/2014
parttime
101
1/18/2014
fulltime
102
1/1/2014
seasonal
102
1/18/2014
fulltime
103
1/1/2014
partime
103
1/18/2014
fulltime
104
1/4/2014
parttime
104
1/18/2014
fulltime
Table 3
employee
status
hours
position
workday
weekend
payday
101
parttime
8
assistant
1/1/2014
1/3/2014
1/3/2014
101
parttime
8
assistant
1/3/2014
1/3/2014
1/3/2014
101
parttime
8
assistant
1/4/2014
1/10/2014
1/17/2014
101
parttime
8
assistant
1/5/2014
1/10/2014
1/17/2014
101
parttime
8
assistant
1/7/2014
1/10/2014
1/17/2014
101
parttime
8
assistant
1/8/2014
1/10/2014
1/17/2014
101
parttime
8
assistant
1/9/2014
1/10/2014
1/17/2014
101
parttime
8
assistant
1/11/2014
1/17/2014
1/17/2014
101
parttime
8
assistant
1/13/2014
1/17/2014
1/17/2014
101
parttime
8
assistant
1/14/2014
1/17/2014
1/17/2014
101
fulltime
8
assistant
1/18/2014
1/24/2014
2/14/2014
102
seasonal
7
manager
1/1/2014
1/3/2014
1/3/2014
102
fulltime
7
manager
1/25/2014
1/25/2014
2/14/2014
102
fulltime
7
manager
1/26/2014
1/26/2014
2/14/2014
102
fulltime
7
manager
1/28/2014
1/28/2014
2/14/2014
102
fulltime
7
manager
1/31/2014
1/31/2014
2/14/2014
103
parttime
5
intern
1/1/2014
1/3/2014
1/3/2014
103
fulltime
6
intern
1/31/2014
1/31/2014
2/14/2014
104
parttime
5
supervisor
1/14/2014
1/17/2014
1/17/2014
104
fulltime
6
supervisor
1/30/2014
1/31/2014
1/31/2014Hello David,
Try this query
set dateformat mdy;
declare @EmpHours table
(Employee int,workday date,payday date,hours int,position varchar(50));
insert into @EmpHours values
(101,'1/1/2014','1/3/2014',8,'assistant'),
(101,'1/3/2014','1/3/2014',8,'assistant'),
(101,'1/4/2014','1/17/2014',8,'assistant'),
(101,'1/5/2014','1/17/2014',8,'assistant'),
(101,'1/7/2014','1/17/2014',8,'assistant'),
(101,'1/8/2014','1/17/2014',8,'assistant'),
(101,'1/9/2014','1/17/2014',8,'assistant'),
(101,'1/11/2014','1/17/2014',8,'assistant'),
(101,'1/13/2014','1/17/2014',8,'assistant'),
(101,'1/14/2014','1/17/2014',8,'assistant'),
(101,'1/18/2014','2/14/2014',8,'assistant'),
(102,'1/1/2014','1/3/2014',7,'manager'),
(102,'1/25/2014','1/31/2014',7,'manager'),
(102,'1/26/2014','1/31/2014',7,'manager'),
(102,'1/28/2014','1/31/2014',7,'manager'),
(102,'1/31/2014','1/31/2014',7,'manager'),
(103,'1/1/2014','1/3/2014',5,'intern'),
(103,'1/31/2014','1/31/2014',6,'intern'),
(104,'1/14/2014','1/17/2014',5,'supervisor'),
(104,'1/30/2014','1/31/2014',6,'supervisor');
--select * from @EmpHours
declare @EmpStatus table
(employee int,start_date date,status varchar(20));
insert into @EmpStatus values
(101,'1/1/2014','parttime'),
(101,'1/18/2014','fulltime'),
(102,'1/1/2014','seasonal'),
(102,'1/18/2014','fulltime'),
(103,'1/1/2014','partime'),
(103,'1/18/2014','fulltime'),
(104,'1/4/2014','parttime'),
(104,'1/18/2014','fulltime');
WITH C AS
SELECT es.employee,es.start_date, es.status, ROW_NUMBER() OVER(partition by employee ORDER BY start_date) AS rownum
FROM @EmpStatus ES
CTE_RANGES as(
SELECT cur.employee,Cur.start_date start_range, cur.status,case when nxt.start_date is null then '2099-12-31' else dateadd(d,-1,Nxt.start_date) end AS end_range
FROM C AS Cur
left JOIN C AS Nxt
ON Nxt.rownum = Cur.rownum + 1 and cur.employee=nxt.employee)
select eh.*,es.status from @EmpHours EH join CTE_RANGES Es on EH.Employee =es.employee and EH.workday between es.start_range and es.end_range
--where es.employee=101
You will need a calender table too which can be joined to the output of the above query to get the weekend dates.
You can find the T-SQL code to generate the calender here
http://stackoverflow.com/questions/19191577/t-sql-function-to-generate-calendar-table
and posting the questions with necessary DDL , DML (like I have posted) would help us a lot.
Satheesh
My Blog -
Required to create a script for base table update using XMLSTORE package.
Hi can anybody provide me some help full suggestion on how to update base table using XMLSTORE package.
I created a simple script for Employee table and can able to do the basic operation like Insert and update on the table.
Query is as follow's
DECLARE
insCtx DBMS_XMLSTORE.ctxType;
rows NUMBER;
xmlDoc CLOB :=
'<ROWSET>
<ROW num="1">
<EMPLOYEE_ID>922</EMPLOYEE_ID>
<SALARY>1801</SALARY>
<HIRE_DATE>17-DEC-2007</HIRE_DATE>
<JOB_ID>ST_CLERK</JOB_ID>
<EMAIL>RAUSSJACK</EMAIL>
<LAST_NAME>JACK</LAST_NAME>
<DEPARTMENT_ID>20</DEPARTMENT_ID>
</ROW>
<ROW>
<EMPLOYEE_ID>923</EMPLOYEE_ID>
<SALARY>2001</SALARY>
<HIRE_DATE>31-DEC-2005</HIRE_DATE>
<JOB_ID>ST_CLERK</JOB_ID>
<EMAIL>PATHAK</EMAIL>
<LAST_NAME>PRATIK</LAST_NAME>
<DEPARTMENT_ID>20</DEPARTMENT_ID>
</ROW>
</ROWSET>';
BEGIN
insCtx := DBMS_XMLSTORE.newContext('EMPLOYEES'); -- Get saved context
DBMS_XMLSTORE.clearUpdateColumnList(insCtx); -- Clear the update settings
-- Set the columns to be updated as a list of values
DBMS_XMLSTORE.setUpdateColumn(insCtx, 'EMPLOYEE_ID');
DBMS_XMLSTORE.setUpdateColumn(insCtx, 'SALARY');
DBMS_XMLSTORE.setUpdateColumn(insCtx, 'HIRE_DATE');
DBMS_XMLSTORE.setUpdateColumn(insCtx, 'JOB_ID');
DBMS_XMLSTORE.setUpdateColumn(insCtx, 'EMAIL');
DBMS_XMLSTORE.setUpdateColumn(insCtx, 'LAST_NAME');
DBMS_XMLSTORE.setUpdateColumn(insCtx, 'DEPARTMENT_ID');
-- Insert the doc.
rows := DBMS_XMLSTORE.insertXML(insCtx, xmlDoc);
--COMMIT;
DBMS_OUTPUT.put_line(rows || ' rows inserted.');
-- Close the context
DBMS_XMLSTORE.closeContext(insCtx);
END;
SELECT employee_id, LAST_name FROM employees WHERE employee_id = 114;
DECLARE
updCtx DBMS_XMLSTORE.ctxType;
rows NUMBER;
xmlDoc CLOB :=
'<ROWSET>
<ROW>
<EMPLOYEE_ID>114</EMPLOYEE_ID>
<LAST_NAME>PRABHU</LAST_NAME>
</ROW>
</ROWSET>';
BEGIN
updCtx := DBMS_XMLSTORE.newContext('EMPLOYEES'); -- get the context
DBMS_XMLSTORE.clearUpdateColumnList(updCtx); -- clear update settings
-- Specify that column employee_id is a "key" to identify the row to update.
DBMS_XMLSTORE.setKeyColumn(updCtx, 'EMPLOYEE_ID');
rows := DBMS_XMLSTORE.updateXML(updCtx, xmlDoc); -- update the table
DBMS_XMLSTORE.closeContext(updCtx); -- close the context
commit;
END;
Nowi want little modification on this above query like as i am passing static XML tags and i want it to pick the dynamic XML from web and use the XMLSTORE for the update.
and also for complex XML having 2-3 levels how this query needs to be changed.As i am new to this Oracle utillity any help from xepert will be a great help for me.
ThanksNowi want little modification on this above query like as i am passing static XML tags and i want it to pick the dynamic XML from webFrom a Web Service?
You'll need UTL_HTTP or HttpUriType interface to send the request and receive the XML response.
Search in the forum, there are already a lot of useful examples available.
and also for complex XML having 2-3 levels how this query needs to be changed.DBMS_XMLStore is OK for readily processing a canonical XML format (/ROWSET/ROW/COLUMN structure or alike).
However, if you have to deal with a more complex structure, you either have to :
- use a target object table that matches the XML structure
- preprocess the input document using XSLT to transform it to canonical format
That's why DBMS_XMLStore is not appropriate for multilevel documents, especially if they contain nested repeating groups.
In this case, XMLTable is a more flexible way of parsing the XML and process it relationally at the same time.
Depending on the size of the document, performance may be improved with schema-based object-relational storage.
For more help, please post a new thread in the {forum:id=34} forum, with the following information :
- database version (select * from v$version)
- a sample XML document (the complex one)
- DDL of your target table
- mapping between XML elements and columns (ie which tag goes to which column?)
- an XML schema (if you have one) -
How to get SQL script for generating table, constraint, indexes?
I'd like to get from somewhere Oracle tool for generating simple SQL script for generating table, indexes, constraint (like Toad) and it has to be Oracle tool but not Designer.
Can someone give me some edvice?
Thanks!
m.I'd like to get from somewhere Oracle tool for
generating simple SQL script for generating table,
indexes, constraint (like Toad) and it has to be
Oracle tool but not Designer.
SQL Developer is similar to Toad and is an Oracle tool.
http://www.oracle.com/technology/products/database/sql_developer/index.html -
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 -
Please send an query for update trigger for those tables .
1: ap_suppliers
2: ap_supplier_sites_all
3: ap_supplier_contacts.
Thanks,
Chaitanya.Hi,
Actually ID and Data are different names in my API. Here I mentioned like that.
Am using Oracle 10g version.
Yes I am going to get the multiple values using this Ref Cursor. The same ref cursor is used in another API of my package.
In this API, the user actually enters Application_id and data. API should insert/update the version_master table with the inputs. See application_id is the foriegn key for app_master table.
The requirement is whenever they enters application_id and data, if application_id already present in the version_master table, then the data should be updated and we should get a status flag for this using Out variable(i.e. using ref cursor only we are showing the status). if the application_id is not present in the version_master table, new record should be inserted. The sequence will generate the version_id for version_master table.
But the Merge statement is working fine for update and insert also. Problem is am unable to see the success or failure through ref cursor. I don't know how exactly I can use this.
If data is NULL the operation should be failed. i.e. I should get Failure status here. But am not getting this.
Please remove the comments here and then check. If I use the NVL2 function I was able to get the status flag, i.e. S or F.
OPEN resultset_o FOR
SELECT NVL2 (data, 'S', 'F')
FROM version_master
WHERE application_id = application_id_i;
1.How the value of data being not null will determine Success of the api and how null failure
2.If the above select statement goes in to exception when others how I will no the failure
I have to achieve the above scenarios.
Please advice me. -
How to find out the script for the table using SQL
Hi,
Could any one tell me that how to find out the script for the table using SQL.
Thanks,
kamalKamal,
You can find the SQL query in Advanced tab of Answers
Thanks,
Balaa... -
Underlying SQL or SQL Script for Calculated Views Create Graphically
Hello,
Is it possible to view the SQL or SQL script generated for calculated views that are created graphically?Hi Mike,
For your calculation view you will find the corresponding column view created in schema '_SYS_BIC'-->Column Tables->
<packagename>/<Calculation view> --> Open Definition of this and check the 'create statement'.
Note: This is a information modeler generated SQL script which will show the generated Calculation Scenario and the respective Column View.
Regards, Rahul
Seems the answer was already given by Murali while I typed
Edited by: Rahul Pant on Mar 2, 2012 5:22 AM -
Shell script for online table redefinition
Hi,
Could someone help me out in building a script for online table redefinition in AIX 11g, moving the table into a new table space.
ThanksYou are embarking upon a voyage in which you will expend a substantial effort reinventing the wheel.
Look at Oracle DBMS_REDEFINITION built-in package.
http://www.morganslibrary.org/reference/pkgs/dbms_redefinition.html
and never do something outside the database, in a proprietary language, that can be done far more efficiently inside the RDBMS in a platform independent language.
In other words, inside the database, I could code your entire project with error handling, in far less than an 15 minutes including testing.
With a simple DDL statement, issued at the command prompt in SQL*Plus ... I could do it in less than 15 seconds: Your choice.
ALTER TABLE <table_name> MOVE TABLESPACE <new_tablespace_name>; -
can we create sql scripts in ssis ; just like we create new excel files on package execution .
well I simplified requirement:
I want to run an SP and run this query and return the below update statement as output.
:select BusinessEntityID, into #temp from [HumanResources].[Employee]
where jobtitle ='Engineering Manager'
update ph
set ph.payfrequency=10*2
from [HumanResources].[EmployeePayHistory] ph where BusinessEntityID in (select * from #temp)
Hi Chelseasadhu,
Do you want to generate such an T-SQL script as you posted above or you want to execute the above script in a SSIS package? If the former, there is not a stock task/component in SSIS can generate T-SQL script; if the later, you can execute
the script via Execute SQL Task. One option is to use Script Task or Script Component to generate SQL script via SQL Server Management Objects (SMO):
http://www.mssqltips.com/sqlservertip/1833/generate-scripts-for-database-objects-with-smo-for-sql-server/
http://msdn.microsoft.com/en-IN/library/ms162153.aspx
Regards,
Mike Yin
TechNet Community Support -
How to add a new data element for existing table filed(Primary key field)
Hi Experts,
How to add a new data element for existing table field(Primary key field)
For this filed ther is no foreign key relation ships and even check table.
while activating table it is giving message like below.
can you help any one to solve this and wil steps to add new dataelement for existing primary key filed of a table.
Check table (NAMING SPACE/TABLE NAME(EX:/TC/VENDOR)) (username/19.02.10/03:29)
Primary key change not permitted for value table /TC/VENDOR
Check on table /TC/VENDOR resulted in errors
Thanks
RaviHi,
Easiest way is to download the table eg into an Excel table (if possible) or text table. Drop the table from the database. Build your table with the new key field. Build the database table again and fill it.
You can do it also over the database into a new table. Drop the old one. Build the enhanced one and fill it. Afterwards drop your (temporary) table.
Maybe there are other ways, but this works.
Success,
Rob
Maybe you are looking for
-
Greetings Experts I run an email address through Outlook 2013 on my PC. I want to synch my Outlook Contacts and Calendar to my iPhone 4 but iTunes isn't doing it and 3 Verizon stores have failed. Advice? Suggestions? Solutions? Thanks JohnnieBGo
-
SWOD. 2nd install OS X won't go
Hi there, wounder if you could help me out here on this issue. On my MacBookPro 2008 i installed the latest IOS update, X Maverick. As many of us, my problem started with growing pains of Wheel of Death. At last all my moc=ves were followed by this
-
Is there a way to invoke DBMS_CRYPTO directly from SQL?
When I try to do this:- INSERT INTO MyTable ( MyName ) VALUES DBMS_CRYPTO.ENCRYPT(UTL_I18N.STRING_TO_RAW ('Graeme', 'AL32UTF8'), DBMS_CRYPTO.ENCRYPT_AES128 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5, UTL_I18N.STRING_TO_RAW('0123456789ABCDEF', 'A
-
Can In Design CS 5.5 add a "BEVEL" to a letter?
Can In Design CS 5.5 add a "BEVEL" to a letter?
-
Report not showing proper output in apps 11i
Hi, I am new to oracle Apps 11i. I Have created customized reports . But Layout showing in builder and oracle apps 11i are different. The differernce is distance between the fields. Also labels and fields not showing full (truncating) value. But the