Help! Need to generate SQL script file in every build of every changes in database project on TFS

Hi everyone,
            I want to accomplish a task in TFS that I need to auto generate the database changes as SQL script file in drop folder for every build.
For ex.: If I add a table in a database and then check in the changes, I need to get that create table script in the drop folder as .sql file extension
I want to automate the build too for every check in. Help me out and guide me a step by step procedure because since I am new to TFS build in visual studio.
Thanks

Check out SSDT:
https://msdn.microsoft.com/en-us/data/tools.aspx
It can generate a DACPAC which can be used to update a SQL Database through the commandline. To ensure that the .sql file executed is compatible with the target database schema it contains a compiled version of teh schema and will generate the change script
on-the-fly.
If you want, you call SqlPackage,exe to generate a SQL script if you want to inspect it before executing.
https://msdn.microsoft.com/en-us/library/hh550080%28v=vs.103%29.aspx
My blog: blog.jessehouwing.nl

Similar Messages

  • Unable to generate SQL trace file on a 10.2.0.1.0 database

    Hello,
    I am unable to generate SQL trace files on a 10.2.0.1.0 database (OS is Win2003 server 64 bits).
    First I tried the way I used to do it on older databases (8i and 9i) :
    execute dbms_system.set_sql_trace_in_session(sid, serial#, true);
    I got no error, but no file was created in the user dump dest directory.
    Then I've been searching and I've tried other things :
    - I changed the user_dump_dest parameter
    - I changed the tracefiles_public parameter value to "true", by modifying the init.ora file
    - I tried another package :
    exec dbms_monitor.session_trace_enable(139)
    Nothing worked, I can't create any trace file...
    Does anyone have an idea about this issue ?
    thank you for you help !
    Antoine

    Hello,
    thank you all for replying.
    I have 2 instances on this machine, and I've just realized that with the other one I have no problem to generate sql trace files as usual.
    But why the hell is it impossible on the first instance ? What difference between the 2 instances can explain this ?
    This is pretty weird...
    Otherwise I am experiencing serious performance problems on the instance where I can't creat trace files, there must be something wrong with it, but I can't figure it out
    regards,
    Antoine

  • Need to generate the excel file with diffrent sheets using utl_file package

    Hi,
    Sorry for previous message in which I had missed the usage of " UTL_FILE " package
    I need to generate the excel file with diffrent sheets . Currently I am generating the data in three diffrent excel files using
    " UTL_File " package and my requirement is to generate this in a single excel file with diffrent sheets.
    Please help on this
    Thanks & Regards,
    Krishna Vyavahare

    Hello 10866107,
    at Re: How to save a query result and export it to, say excell? you can find links to different solutions. At least the packages behind second and fourth link support more than one worksheet.
    Regards
    Marcus

  • Calling a sql script file from a function.

    Hi,
    I need to call a sql script file from a user defined function. Currently i am trying to do this in Oracle SQL Developer. i tried calling with
    @ {filename}, EXECUTE IMMEDIATE etc, but nothing worked. I get the Compiler error.
    Basically my need is to call catldap.sql file so that DBMS_LDAP package gets loaded and then I can call the API functions from this.
    Please let me know if this is possible doing in a PL/SQL function.
    thanks,
    Naresh

    user784520 wrote:
    I need to call a sql script file from a user defined function. Not possible.. and it seems that you do not fully understand the client-server within the Oracle context.
    All SQL and PL/SQL are parsed and executed by an Oracle server process. The SQL and PL/SQL engines each expects a single command block at a time. Neither of these can accept a series of separate commands as a single call and then execute each in turn. The SQL engine expects a single SQL statement at a time. The PL engine expects a single PL/SQL anonymous block at a time.
    This server process also cannot break into the local file system to access script files. Nor can it hack across the network to access script files on the client.
    In order for the server process to access local files, a directory object needs to be created and the current Oracle schema needs read and/or write access on that directory object. As sound security principles apply.
    There's no PL/SQL command to execute a script. You must not mistake SQL*Plus commands (this client has a very limited vocabulary) with PL/SQL commands. SQL*Plus executes its own commands.. and send SQL and PL/SQL commands (a statement block a time) to the Oracle server process to be serviced and executed.
    It is also a very bad idea to execute external script contents from inside an Oracle server process - as that script resides externally and thus outside Oracle's security mechanisms. This means that is is pretty easy for someone to access that script, compromise it, and then have you inject and execute the contents of that script into the database.
    It is not sound security.
    Last issue - it is even worse to have application PL/SQL code dynamically creating (or trying to create) portions of the Oracle data dictionary and PL/SQL call interface.
    The database needs to be installed correctly - and this includes loading and executing the required rdbms/admin scripts during database installation. It does not make sense at all for application code to try and execute such scripts. It raises numerous issues, including having to allow that application code full and unrestricted SYS access to the database instance. A very serious security violation.
    I do not agree at all with the approach you want to use.

  • Running sql script files to re create database

    We have having around 10 sql script file that has sql statments inside it (example insert .... delete...update.... etc).Right now what we do is that in jdbc we open each script file, and read each line ,and then make jdbc call run jdbc for each sql statement inside the file.
    Wondering if there is a better way to do this.
    Right now the challenges are
    1)The process goes wrong if there is an extra semi colon ...or extra space after a statments...etc...Basically I find this way of creating data odd...
    2)it is slow because of the network traffic between application server and database server for every sql statements that gets executed.The solution for this issue is to do a batch update....But still I dont like this solution.
    Can someone give me any better idea.
    I am thinking to have all this sql script moved to a store procedure (rather than inside the sql script file) .JDBC then can pick this store procedure sql file ,and create this store procedure via jdbc, and then execute this store procedure.
    This will be faster because all the sql will be running in the databsase.Only one trip to database to call this store procedure.
    Is this a good idea ?
    thx
    m

    Manjit wrote:
    We have having around 10 sql script file that has sql statments inside it (example insert .... delete...update.... etc).Right now what we do is that in jdbc we open each script file, and read each line ,and then make jdbc call run jdbc for each sql statement inside the file.
    Wondering if there is a better way to do this.
    Right now the challenges are
    1)The process goes wrong if there is an extra semi colon ...or extra space after a statments...etc...Basically I find this way of creating data odd...
    2)it is slow because of the network traffic between application server and database server for every sql statements that gets executed.The solution for this issue is to do a batch update....But still I dont like this solution.
    Can someone give me any better idea.
    I am thinking to have all this sql script moved to a store procedure (rather than inside the sql script file) .JDBC then can pick this store procedure sql file ,and create this store procedure via jdbc, and then execute this store procedure.
    This will be faster because all the sql will be running in the databsase.Only one trip to database to call this store procedure.
    Is this a good idea ?
    thx
    mI'm not 100% sure i follow (it's Friday and i have a mild case of ADD).
    Are you suggesting having the Java application create procedures in the database on the fly? If so i would say that's not a good idea.
    Create the stored procedures in the database, have Java call them as needed to process data.
    If you need to load copious amounts of data, look in to external tables, it's possible they could come in handy for what you are doing .... or not ... again, it's hard to say given i find your description of what's currently happening somewhat confusing.

  • How to generate .SQL format file from oracle database?

    How to generate .SQL format file from oracle database?
    I have a database of Oracle 8.1.6,now want to generate script file (including table structure,index,etc.) from it,What should I do?
    Thanks.

    Your question pertains to the Database Export/Import. This forum exclusively focusses on the export/import utilities that come along with "Oracle Portal" which is a web-based tool. Could you please post your question under the RDBMS export/import or migration forum.

  • Generate sql scripts

    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 can I run a SQL script file...

    How can I run a SQL script file from a location on my computer without providing the whole path?
    Is there some way I can set a "Working folder" in SQL Plus??
    Thanks!
    Tom

    You can create an environment variable called "SQLPATH" which is a list of directories that SQL*Plus will search for your .SQL
    scripts.
    I would like to use another directory than the oracle/bin...
    How can I do this ??
    Hello,
    U can do this by this way:
    Save odm_script.sql file to the default Oracle
    directory i.e. Oracle-Home/bin and Run following command
    through SQL Plus.
    SQL>@Script_Name
    I hope this will resolve ur problem.
    Regards,
    Omer Saeed Khan.

  • App-V 5.0 SP3 SQL Script modifications (KB3031340) Required for both Management and Reporting Databases?

    Can anyone confirm if I need to modify the InsertVersionInfo.sql and Permisioins.sql scripts for both the APP-V Management and Reporting databases?  KB3031340 only references the Management Database, but I suspect it is required for both.
    Thank You!

    It should only apply to Management Database. There weren't any changes to the Reporting DB AFAIK.
    Steve Thomas, Senior Consultant, Microsoft
    App-V/MED-V/SCVMM/Server App-V/MDOP/AppCompat
    http://blogs.technet.com/gladiatormsft/
    The App-V Team blog: http://blogs.technet.com/appv/
    The MED-V Team Blog: http://blogs.technet.com/medv
    The SCVMM Team blog: http://blogs.technet.com/scvmm/
    “This posting is provided "AS IS" with no warranties, and confers no rights. User assumes all risks.”

  • 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
    -AKJ

    But 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.

  • Generate SQL scripts from Designer 6

    Hi all,
    Does anyone know how to generate an SQL-script from Designer? I want to maintain the code in the repository, and also document usages against the script. I've found ways to document the script, but then I can't generate it....
    Thanks in advance,
    Ronald

    Ronald,
    How did you record the SQL script in designer? As undefined pl/sql module (type= "null")?
    If so, you cannot generate the script with the ddl generator. To do so you could change the type to procedure and make post-generation changes to the script (cut of f the procedure header and trailer lines). An other way to generate it is to write your own SQL script generator as a headstart utility. You might take a look at the html help file generator utility which does a similar job (create a o/s file based on the repository contents).
    Let us know if you succeed.
    Regards, Marc
    null

  • Need to Generate a eText File for Payments

    Hi,
    I have a requirement to generate a eText Outbound file using Payment Process profile. I have understand the basic steps and template we need to use to generate the eTEXT output.
    Q1. But here is my question is that the XML tags will be repeated for more than one invoice then the below tags will repeat like this. For this case how to read the two blocks.
    Normal rtf we will use the loop condition but here how to use this in eTEXT file format. Please provide some example.
    Q2. And also if the multiple blocks will contains different data but here I need to print all the data in a single line up to a fixed length then again I go for second line if the fixed length
    reaches the maximum limit.
    <DocumentPayable>
    <DocumentNumber>
    <DocumentInternalIDSegment1>30076</DocumentInternalIDSegment1>
    <DocumentInternalIDSegment2>83026</DocumentInternalIDSegment2>
    </DocumentPayable>
    </DocumentNumber>
    <DocumentPayable>
    <DocumentNumber>
    <DocumentInternalIDSegment1>100100</DocumentInternalIDSegment1>
    <DocumentInternalIDSegment2>123456</DocumentInternalIDSegment2>
    </DocumentPayable>
    </DocumentNumber>

    Hi Prasana,
    Here is the dll compile in CVI. You should be able to use the file import the driver.
    The best thing would be for you to be able to compile the driver in case you want to modify something. You will also need to install the CVI run-time engine:
    CVI Run-time Engine
    With a little work you could compile the driver with MSVC++. You just need to replace some functions. At a glance, this are some of the functions that need to be changed.
    The first thing would be to use the NI-488.2 driver interface for MSVC++. You would only need to replace the header file with the ni488.h file. It would be a good idea to replace the OpenDev a
    nd CloseDev functions with the ibdev and ibonl functions. Make sure you include the object file in your project settings.
    The other function, which might require more work is the Fmt function. This is a CVI specific function to perform string formatting. You could replace with one of the standard library C functions, such as sprintf, to do the formating. Or you could redefine the Fmt using these standard functions.
    Hope this helps.
    DiegoF
    National Instruments.
    Attachments:
    hp8165.dll ‏50 KB

  • How to run SQL script file on Linux using Java ?

    Hi,
    I need to execute .sql file using java. I used following approach for this.
    private void runScriptEvent(java.awt.event.ActionEvent evt) {                               
            String sqlOutput = "";
            String sqlPromptLines="";
            String currentFunctionName = "";
            if(con!=null){
                String userName = jTextField4.getText();
                String password = jPasswordField1.getText();
                String databaseName = jTextField3.getText();
                try {
                    String script_location = "";
                    ProcessBuilder processBuilder =null;
                    Process process = null;
                    //File file = new File("C:/ScriptFile");
                    File file = new File("./SQL_Script");
                    //File file = new File("E:\\install\\SQL_Script");
                    if(file.exists()){
                        File [] list_files= file.listFiles(new FileFilter() {
                                        public boolean accept(File f) {
                                        if (f.getName().toLowerCase().endsWith(".sql"))
                                        return true;
                                        return false;
                    int count = 0;
                        for (int i = 0; i<list_files.length;i++){
                            script_location = "@" + list_files.getAbsolutePath();//ORACLE
    //currentFunctionName = list_files[i].getName();
    StringTokenizer st = new StringTokenizer(list_files[i].getName(), ".");
    while(st.hasMoreTokens()) {
    currentFunctionName = st.nextToken();
    String extention= st.nextToken();
    System.out.println("Function Name = "+currentFunctionName + "\t Extention = " + extention);
    processBuilder = new ProcessBuilder("sqlplus",userName+"/"+password+"@"+databaseName, script_location); //ORACLE
    processBuilder.redirectErrorStream(true);
    process = processBuilder.start();
    BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
    String currentLine = null;
    while ((currentLine = in.readLine()) != null) {
    sqlPromptLines = " "+sqlPromptLines + currentLine +"\n";
    count ++;
    System.out.println(count+" " + currentLine);
    if(currentLine.equalsIgnoreCase("Function created.")){
    sqlOutput = "\n" sqlOutput currentFunctionName + " " currentLine"\n" ;
    break;
    }// end while
    in.close();
    process.destroy();
    }//end for
    }//end if file exists
    } catch (IOException e1) {
    jTextArea1.setText(e1.getMessage());
    System.out.println("Script Done");
    jTextArea1.append(sqlOutput);
    }// end id Connection is not null
    Above code working appropriate on Windows but not on Linux.
    is there any changes needed ?
    Regards,
    Ajay
    Edited by: Ajay Sharma on Nov 21, 2012 6:43 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi gimbal2,
    about code
    jTextArea1.setText(e1.getMessage());I am using this code so that the user will be prompted with a message rather than stack trace.
    About the issue I am getting on linux i believe its because of following statement.
    processBuilder = new ProcessBuilder("sqlplus",userName+"/"+password+"@"+databaseName, script_location); //ORACLERegards,
    Ajay
    Edited by: Ajay Sharma on Nov 23, 2012 12:05 PM
    Edited by: Ajay Sharma on Nov 23, 2012 12:06 PM

  • Using an SQL Script file to create database in Java? (monkeyDB.sql)

    Hello!
    I am a writing an SQL Script so that I can re-create my database on another server (im using my laptop to test it on first though).
    I'm connecting to mySQL server using JDBC which works fine, but I was wondering
    how can I run an entire script file, say myScript.sql from within a Java class??
    (an SQL Script is simply a file containing the regular SQL commands and expressions that you might enter at an sql command line prompt)
    example of an SQL Scritp: monkeyDB.sql>>
    //#create new db
    CREATE DATABASE sample_db;
    //#set active db
    USE sample_db;
    //#set table paramaters
    CREATE TABLE monkeys
    (name CHAR(20),
      age INT UNSIGNED,
      sex ENUM('M','F')
    //#create standard monkeys
    INSERT INTO monkeys(name,age,sex) VALUES("Sammy",10,"M");
    INSERT INTO monkeys(name,age,sex) VALUES("Muncht",12,"M");
    INSERT INTO monkeys(name,age,sex) VALUES("Jill",8,"F");
    //#get recordset
    SELECT * FROM monkeys WHERE age < 50;Thanks for your help!

    thanks. :-)
    I thought about that too but I didnt want to hard wire it into the code.
    I guess it isnt possible to output the script file using some command from the sql library..?

  • Not able to read sql script file in ADF mobile

    hi,
    i am trying to create some DB tables in SQLLite DB (similar to the HR sample app where it creates bunch of DB objects using hr.sql file in .adf/META-INF)..
    but i am getting following error at runtime. i placed the file in .adf/META-INF directory in my application.
    "sqllite returned: error code=14, msg = cannot open file at source...."
    what am i missing here?
    please help.
    regards,
    ad

    This how I have done it.
    This is the start method from my Listener:
      public void start()
          String databaseName = "mydatabase";
          File dbFile = new File(AdfmfJavaUtilities.getDirectoryPathRoot(AdfmfJavaUtilities.ApplicationDirectory)+"/"+databaseName+".db");
          if(!dbFile.exists())
                try {
                    this.initializeDatabase(databaseName);
                } catch (Exception e) {
                    System.out.println(e.getMessage());
      }And this is a custom method also in the listener class
      private static void initializeDatabase(String databaseName) throws Exception
          List stmts = null;
          try {
              ClassLoader cl = Thread.currentThread().getContextClassLoader();
              InputStream is = cl.getResourceAsStream(".adf/META-INF/"+databaseName+".sql");
              if (is == null) {
                  // .sql script not found
              BufferedReader bReader = new BufferedReader(new InputStreamReader(is));
              stmts = new ArrayList();
              String strstmt = "";
              String ln = bReader.readLine();
              while (ln != null) {
                  if (ln.startsWith("REM") || ln.startsWith("COMMIT")) {
                      ln = bReader.readLine();
                      continue;
                  strstmt = strstmt + ln;
                  if (strstmt.endsWith(";")) {
                      System.out.println(strstmt);
                      stmts.add(strstmt);
                      strstmt = "";
                      ln = bReader.readLine();
                      continue;
                  ln = bReader.readLine();
              String Dir = AdfmfJavaUtilities.getDirectoryPathRoot(AdfmfJavaUtilities.ApplicationDirectory);
              String connStr = "jdbc:sqlite:" + Dir + "/"+databaseName+".db";
              Connection conn = null;
              conn = new SQLite.JDBCDataSource(connStr).getConnection();
              conn.setAutoCommit(false);
              for (int i = 0; i < stmts.size(); i++)
                  Statement pStmt = conn.createStatement();
                  pStmt.executeUpdate((String)stmts.get(i));
              conn.commit();
              conn.close();
          } catch (Exception ex)
              ex.printStackTrace();
          }My .sql scrip named "mydatabase.sql" located in the ADF META-INF folder.
    See this picture :
    http://upload.wiim.be/img/Screenshot%20at%20jan.%2019%2011-39-30.pngDon't forget the register your Listener class to the adfmf-application.xml file!
    http://upload.wiim.be/img/Screenshot%20at%20jan.%2019%2011-42-24.png

Maybe you are looking for

  • How can I delete an infected file from backup folders

    ran Sophos anti-virus recently and it told me I have a malicious trojan on my Mac, Mal/PDFEx-H (which supposedly only affects windows, but it turned up anyway.) Sophos couldn't remove it automatically, so I was instructed to do a manual removal; howe

  • Posting with a fixed coster by gl account

    Hi, When i run the RPCIPE00, i would like that some gl account have a fixed cost center and not the cost center define by default in the infotype 0001. I have customized this : OKB9 + Set Up Fixed Costs Postings (SPRO) in the source and destination s

  • SQL Prompt not responnding

    Hi Everybody, Database version:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production Os: Solaris 10 After i am executing the following statement in sqlplus............ SQL> alter database backup controlfile to trace; It s not c

  • RAC 10.2.0.5 - Session waiting forever

    Hi, i feel alone The database has several sessions that are waiting forvever. Sometimes these sessions are wainting for "direct path read", or "read by other session" The objects on which the sessions are waiting are never the same (user table, or LO

  • Increase max number of adjustments?

    Does anyone know of a way to increase the maximum number of adjustment bricks for any one type of adjustment? I believe the current limit is 5, but sometimes when working with ver complex photos I find the need to go beyond this limit. In particular,