How to execute sql files with windows path ?

Hi , here's my stupid question :
I have my parent SQL script say A.sql in directory C:\program files\my files\A.sql
A.sql has calls to multiple sql files like this
@@1.sql;
@@2.sql;
When I call A.sql using sqlplus as:
sqlplus <username> <connection_string> @"C:\program files\my files\A.sql"
A.sql gets executed but then while calling "1.sql" it fails with the error
SP2-0310: unable to open file "C:\program.sql"
This is happening because of the space, how can this be handled. thx in advance :)
Regards,
Neuron

my A.sql is:
@@1.sql
@@2.sql
1.sql and 2.sql are in the same directory as A.sql.
sqlplus <username> <connection_string> @"C:\program files\my files\A.sql"
VG2,
Yes. Specify the entire path/filename and put double quotes around itA.sql has the double quotes around it, however what additional things can be done so that 1.sql and 2.sql which are present in same directory as A.sql also runs.
Ashish,
Yes the assumption is correct. Although when I cd to this directory then this issue won't come for sure.
But the requirement is you can't 'cd' to the directory and want to execute with complete path.
There is no issues in Solaris as the space is not allowed.

Similar Messages

  • How to execute .sql file in Stored Procedure?

    Hi,
    I have an urgent requirement, where i have to execute .sql file form Stored Procedure.
    This .sql file will have set of update statement. I need to pass value to this update statement.
    Kindly please help me.
    Regards,
    Irfan

    This is required as part of Data Migration where  i have to do 100 of table's update. Each time update table will defer, so its better to have in separate script file (.sql). Can u paste some sample/syntax to exceute .sql file from stored procedure. I am new to this PL/SQL.
    How have you determined that it's "better" to have seperate scripts?  I assume you mean the table name will "differ" (and not "defer" - I assume that's just because English isn't your first language? no problem - I think I understand what you're asking).
    So what I think you're asking is that you have dynamic table names but each table needs to be updated in the same way?
    Question: Why do you have tables with different names that all need the same process doing to them?
    Assuming it's a valid requirement (and 99% of the time doing dynamic coding implies it's not).... you could use dynamic code, rather than 'scripts'...
    e.g.
    create procedure update_table(tbl_name varchar2) is
    begin
      execute immediate 'update '||tbl_name||' set lastupdate = null';
    end;
    As you haven't bothered to provide a database version, any example code/data or explanation of what you're actually doing, you're not going to get any detailed answer.  Please do take the time to read the FAQ and post appropriate details so people can help you.

  • How to execute .sql file

    hi,
    i want to execute .sql files in sql plus from a fixed location whether it may be network location or from system drive. so that i can use it from other computers when i will be working on different pc.
    so please tell me for network location solution and from drive. by default it fetch from BIN directory
    i am using oracle 10g.
    thanks

    Hi FRNzzz!! wrote:
    if the .sql files are placed on some network place then also i just need to put the path of that directory ? Sure. You can either set up a desktop shortcut for SQL*Plus using the remote folder as the "Start in" location, or (what I usually do) drag the script file into your SQL*Plus window.
    Edited by: William Robertson on Feb 26, 2011 2:21 PM

  • How to execute .sql file using ODI

    Hi All,
    I need to execute .sql file using ODI.
    I tried @{path}{file} command in ODI procedure selecting oracle technology.but it is failing.
    Do any one have any other idea to execute .sql file.
    Thanks in advance

    Ohk...I think you can try creating batch file(.bat) if its Windows & call that from ODIOSCommand.
    The bat file should contain scripts which call .sql file using sqlplus  & there you can use @{path}{file} format.
    See if this helps.
    Regards,
    Santy

  • How to execute sql file from servlet

    Hi,
    I am using JSP, Servlets and Oracle 8i in my application. I want to execute .sql file from java code. Is it possible to do that,
    as we execute .sql file from sql plus prompt.
    Suppose I have abc.sql file and I want to execute it from java code.
    If any body have the solution then pl. reply with sample code.
    Thanks,
    Rajesh

    If any body have the solution then pl. reply with
    sample code.No, no, dec - s/he doesn't want the actual solution, but the full code!
    /k1

  • How to execute SQL Script using windows powershell(using invoke-sqlcmd or any if)

    OS : Windows server 2008
    SQL Server : SQL Server 2012
    Script: Test.sql (T-SQL)  example : "select name from sys.databases"
    Batch script: windows  MyBatchscript.bat ( here connects to sql server using sqlcmd  and output c:\Testput.txt) 
     (sqlcmd.exe -S DBserverName -U username -P p@ssword -i C:\test.sql -o "c:\Testoutput.txt)  ---it working without any issues.....
    This can execute if i double click MyBatchscript.bat file and can see the output in c:\testput.txt.
    Powershell: Similarly, How can i do in powershell 2.0 or higher versions?  can any one give full details with each step?
    I found some of them online, but nowhere seen clear details or examples and it not executing through cmd line (or batch script).
    example: invoke-sqlcmd -Servernameinstance Servername -inputfile "c:\test.sql" | out-File -filepath "c:\psOutput.txt"  --(call this file name MyTest.ps1)
    (The above script working if i run manually. I want to run automatic like double click (or schedule with 3rd party tool/scheduler ) in Batch file and see the output in C drive(c:\psOutput.txt))
    Can anyone Powershell experts give/suggest full details/steps for this. How to proceed? Is there any configurations required to run automatic?
    Thanks in advance.

    Testeted the following code and it's working.....thanks all.
    Execute sql script using invoke-sqlcmd with batch script and without batch script.
    Option1: using Import sqlps
    1.Save sql script as "C:\scripts\Test.sql"  script in side Test.sql: select name from sys.databases
    2.Save Batch script as "C:\scripts\MyTest.bat" Script inside Batch script:
    powershell.exe C:\scripts\mypowershell.ps1
    3.Save powershell script as "C:\scripts\mypowershell.ps1"
    import-module "sqlps" -DisableNameChecking
    invoke-sqlcmd -Servername ServerName -inputFile "C:\scripts\Test.sql" | out-File -filepath "C:\scripts\TestOutput.txt"
    4.Run the Batch script commandline or double click then can able to see the output "C:\scripts\TestOutput.txt" file.
    5.Connect to current scripts location  cd C:\scripts (enter)
    C:\scripts\dir (enter )
    C:\scripts\MyTest.bat (enter)
    Note: can able to see the output in "C:\scripts" location as file name "TestOutput.txt".
    Option2: Otherway, import sqlps and execution
    1.Save sql script as "C:\scripts\Test.sql"  script in side Test.sql: select name from sys.databases
    2.Save powershell script as "C:\scripts\mypowershell.ps1"
    # import-module "sqlps" -DisableNameChecking #...Here it not required.
    invoke-sqlcmd -Servername ServerName -inputFile "C:\scripts\Test.sql" | out-File -filepath "C:\scripts\TestOutput.txt"
    3.Connect to current scripts location
    cd C:\scripts (enter)
    C:\scripts\dir (enter )
    C:\scripts\powershell.exe sqlps C:\scripts\mypowershell.ps1 (enter)
    Note: can able to see the output in "C:\scripts" location as file name "TestOutput.txt".

  • How to execute SQL scripts with MaxDB ..?

    Hi all,
    i got some clue from another thread and i observed the command is like
    sqlcli -d DBNAME -u SQLUSER,SQLPASS -i filename.sql -c <delimiter> is there,
    when i use this the only first query is successfully executing,
    this might be problem with delimiter.
    can any body help how to use delimiter in the script file with an example.
    thanks in advance.
    --Hari

    Hi,
    Sample Script
    CREATE TABLE city
    (zip                CHAR (5)    KEY CONSTRAINT zip BETWEEN '10000' AND '99999',
    name               CHAR(20)    NOT NULL,
    state              CHAR(2)     NOT NULL)
    CREATE TABLE customer
    (cno                FIXED (4)   KEY CONSTRAINT cno BETWEEN 1 AND 9999,
    title              CHAR (7)    CONSTRAINT title IN ('Mr', 'Mrs', 'Company'),
    firstname          CHAR (10)   ,
    name               CHAR (10)   NOT NULL,
    zip                CHAR (5)    CONSTRAINT zip BETWEEN '10000' AND '99999',
    address            CHAR (25)   NOT NULL,
    FOREIGN KEY (zip) REFERENCES city ON DELETE RESTRICT)
    \dt customer
    COMMIT
    Regards
    Ayyapparaj

  • How to execute SQL statement with oracle jdev

    Please I'm a beginner in oracle jdeveloper. I want to know how to use and execute sql statememt within oracle Jdeveloper 10 g release 3 to manipulate objects in oracle database. I want for e.g. to Enable/disable trigger using sql statement "ALTER TRIGGER trigername DISABLE" explicitly. Please tell me how to proceed.
    i am sure you can help me
    Sincerly yours.

    Hi,
    Using following tutorial http://www.oracle.com/technology/obe/ADF_tutorial_1013/10131/index.htm
    you will found how to connect from Jdev to a database (chapter 1 or 2 ?). Then you just have to go under Tool>SQL*Plus or Tools>SQL Worksheet depending on what you need.
    Luck,
    Tif

  • How to execute .sql file if it contains unicode characters?

    DB version : 10.2.0.1
    OS : Windwos XP
    Today I got an .sql file which needs to be executed from sql*plus prompt.
    When I am trying I got error as below
    SP2-0042: unknown command " ■I" - rest of line ignored.
    When I checked the .sql file, I found there are Urdu characters (I believe we treat them as unicode) because of which I am facing error.
    Can anyone help me in finding the way to execute this .sql file which contains unicode characters?
    Thanks in advance

    That sql file contains so many insert statements. Here is one such statement
    INSERT INTO MAIN_LAND_TABLE_DEMO(OBJECTID, BLK_ARA_SER_SECTOR_ID, BLK_ARA_AREA_CODE, BLK_BLOCK_ID, PLOT_ID, DOCUMENT_NO, AREA_NAME, OWNER_NAME, PLOT_AREA_SQ_F, PLOT_AREA_SQ_M, PLAN_NUMBER, PLAN_DATE, OLD_BLOCK_ID, OLD_PLOT_ID, LAND_USE, PLOT_DESC, LAND_TYPE, REMARKS, IMAGE_FILE_NAME, PLOT_SIZE_S, PLOT_SIZE_N, PLOT_SIZE_E, PLOT_SIZE_W, BUILDING_HEIGHT, GROUND_LEVEL, NO_OF_FLOORS, REFERENCE_NO, OLD_DRAWING_NO, PERMIT_NO, CUR_CUSTOMER_COD, QC) VALUES(RAK_ISP_SEQ.nextval,1,0,7,71,'','الرمس - ضايه','وقف على مساجد راس الخيمه',10936,1016,'33/2000',TO_DATE('8/5/2000','mm/dd/yyyy'),'','161','سكني','خالية','ملك','','','','','','',0,0,0,'','2000/32','',0,1);

  • How can ipad share files with windows pc?

    Can the iPad be connected to a Windows 7 PC and used to share files between Word and Pages? 

    Word files can be opened and edited in Pages on the iPad and you can send the files to the iPad via email, by using a service like DropBox or by using iOS file sharing. This will explain how to use file sharing.
    http://support.apple.com/kb/HT4094
    You might want to be aware of the fact that some editing features will be lost from the Word files when you open them Pages - fonts will be limited - some formatting issues may arise - Pages on the iPad just doesn't work like Word on a computer.

  • How to share files with windows xp

    how to share files with windows xp

    stephenfromdagenaham wrote:
    how to share files with windows xp
    If you mean just moving files between a Mac and a PC with XP on it, get a USB flash drive, format it FAT32 (they usually come that way) and copy the files to that drive.

  • How do I share files from Windows Vista to a Mac with Lion OSX?

    How do I share files from Windows Vista to a Mac with Lion OSX?  I'm having SO much trouble with this!  Any help would be appreciated!!!

    In a finder window, under 'shared' you should be able to see the windows computer name, click on it and connect to it. I am assuming here you have sharing turned on and permissions granted on the windows computer.
    Will add a note though, I have frequently accessed files from a PC on the LAN using XP, not vista.

  • How to execute sql qurery in st05

    how to execute sql qurery in st05
    thanks in advanced.

    Hi,
    do this....
    1.create a small ABAP/4 program that contains only the select statement. Before proceeding, test it to ensure that it works.
    2.Open that program in the editor so that it is ready and waiting to execute.
    3.Open a new session using the menu path System->Create session.
    4.Run transaction ST05 (enter /nst05-zero-five, not oh-five-in the Command field, or choose the menu path System->Utilities->SQL Trace). The Trace SQL Database Requests screen is displayed.
    5.If the Trace SQL Status Information box reads Trace SQL is switched off, go to step 7.
    6.At this point, the Trace SQL Status Information box contains Trace SQL switched on by, followed by the user id who turned on the trace and the date and time it was started. You must switch it off before you can proceed. If the trace was started within the past hour, it is possible that it is still being used. Contact the indicated user or try again later. If the trace was started hours or days ago, the user probably left it on by mistake and it can be safely turned off. To turn off the trace, press the Trace Off pushbutton. The message in the Trace SQL Status Information box should now read Trace SQL is switched off.
    7.Press the Trace On pushbutton. The Trace SQL Database Requests dialog box is displayed. The DB-Trace for User field should contain your user ID. If your user ID is not in this field, enter it now.
    8.Press the OK button. You are returned to the Trace SQL Database Requests screen and the status information reads Trace SQL switched on by, indicating that you turned on the trace.
    9.Switch back to the window containing your editor session (the one with your program waiting to execute).
    10.Press F8 to run your program. (Only press F8, do not do anything else, do not even press the Back button.)
    11.When your program has run and the hourglass is no longer displayed, switch back to the trace window.
    12.Press the Trace Off pushbutton. The status information reads Trace SQL is switched off.
    13.Press the List Trace pushbutton. The Trace SQL Database Requests dialog box is displayed. The fields on this screen will already contain values.
    14.Press the OK button. You might need to wait a little while, at most a couple of minutes. The Trace SQL: List Database Requests screen is displayed.
    15.Type %sc in the Command field and press the Enter key. The Find dialog box is displayed.
    16.Type the name of the table you are tracing in the Search For field. (This is the table named in the select statement in your ABAP/4 program.)
    17.Press the Find button. A search results list should be displayed with your table name highlighted.
    18.Click on the first highlighted table name. You are returned to the Trace SQL: List Database Requests screen. Your cursor is positioned on the first line containing your table name. To the right of it, in the Operation column, should be the word PREPARE, OPEN, or REOPEN.
    19.Press the Explain SQL button on the Application toolbar. The Show Execution Plan for SQL Statement screen is displayed.
    20.Scroll down to the execution plan. The index used will be displayed in blue.

  • How to execute sql scripts from Powershell across multiple databases

    Re: How to execute sql scripts from Powershell across multiple databases
    I have an tsql script that I want to run across a list of databases. How is the best way to do this in Powershell? Thanks.

    My example below, using just the SMO and not breaking up the batches, the ExecuteWithResults give the following error when the .sql file contains a GO. My script files are as simple as a DECLARE and then a GO.
    WARNING: SQL Script Failed
    The object of type "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not valid or not in the correct sequence. This is likely caused by a user-specified "format-list" comm
    and which is conflicting with the default formatting.
        + CategoryInfo          : InvalidData: (:) [out-lineoutput], InvalidOperationException
        + FullyQualifiedErrorId : ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand
    Also, when executing from the ISE, is there a way to force the ISE to release the files. I am having to close the ISE and reopen my script every time I want to make a testing change to the .sql file.
    [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
    $scriptspath = "C:\temp\psExecuteSQLScripts\scripts"
    $SQLServer = "fidevc10"
    $SQLDB = "Bank03"
    # Create SMO Server Object
    $Server = New-Object ('Microsoft.SQLServer.Management.Smo.Server') $SQLServer
    # Get SMO DB Object
    $db = $Server.Databases[$SQLDB]
    # Load All SQL Scripts in Directory
    $scripts = Get-ChildItem -Path (Join-Path $scriptspath "*") -Include "*.sql" -Recurse
    # Loop through each script and execute
    foreach ($SQLScript in $scripts)
    $fullpath = $SQLScript.FullName
    # Read the Script File into Powershell Memory
    $reader = New-Object System.IO.StreamReader($fullpath)
    $script = $reader.ReadToEnd()
    # Execute SQL
    Write-Host "Executing $SQLScript on $SQLDB...."
    try
    $ds = $db.ExecuteWithResults($script)
    Foreach ($t in $ds.Tables)
    Foreach ($r in $t.Rows)
    Foreach ($c in $t.Columns)
    Write-Host $c.ColumnName "=" $r.Item($c)
    Write-Host "Complete"
    catch [Exception]
    Write-Warning "SQL Script Failed"
    echo $_.Exception|format-list -force
    Write-Host " " -BackgroundColor DarkCyan

  • How to run .sql file in tsql or powershell

    Hi All,
    HOw to run .sql file inside the TSQL or powershell using with IF else condition. This below query works fine but when i executing through the SQL Agent it's geeting an error.Please could help how to run through the SQL agent already using execution type
    in agent as 'Operating system(CmdExec)'
    Declare @computerName varchar(100), @InstanceName varchar(50)                             
    SET @ComputerName = REPLACE(CAST(SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS varchar),'\','$')  
    SET @InstanceName = REPLACE(CAST(SERVERPROPERTY('instancename') AS varchar),'\','$')
    IF (@InstanceName = 'SQL2008R2')
    Begin  
    :r C:\BackupFolder\Test1.sql    
    :r C:\BackupFolder\Test2.sql    
    End
    IF (@InstanceName = 'SQLINS2')
    BEGIN
    :r C:\BackupFolder\Test3.sql
    END
    IF (@InstanceName = 'SQL2012')
    BEGIN
    :r C:\BackupFolder\Test4.sql
    END
    Thansk in Advance
    A-ZSQL

    In T-SQL, you can try using sqlcmd to invoke sql file
    if @@SERVERNAME='abcd'
    begin
    Master..xp_cmdshell 'sqlcmd -S <ServerName> -i BackupDetails.sql -E'
    end
    OR 
     PowerShell 
    Load the snapins
    Add-PSSnapin SqlServerCmdletSnapin100
    Add-PSSnapin SqlServerProviderSnapin100
    Function Get-SqlInstances {
    Param($ServerName = '.')
    $localInstances = @()
    [array]$captions = gwmi win32_service -computerName $ServerName | ?{$_.Name -match "mssql*" -and $_.PathName -match "sqlservr.exe"} | %{$_.Caption}
    foreach ($caption in $captions) {
    if ($caption -like "MSSQLSERVER") {
    $localInstances += $ServerName
    } else {
    $temp = $caption | %{$_.split(" ")[-1]} | %{$_.trimStart("(")} | %{$_.trimEnd(")")}
    $localInstances += "$ServerName\$temp"
    $localInstances
    $instance=Get-SqlInstances -ServerName HQDBSP17
    foreach($i in $instance)
    if($i -like 'CRM2011')
    write-host 'CRM Database'
    invoke-sqlcmd -inputfile 'F:\PowerSQL\test.sql' -ServerInstance 'abcd'
    if( $i -like 'SQL2012')
    write-host 'SQL 2012 instance'
    invoke-sqlcmd -inputfile 'F:\PowerSQL\test.sql' -ServerInstance 'abcd'
    --Prashanth

Maybe you are looking for

  • Transferring all data from a mac to another

    I'm purchasing a new macbook soon, and i wish to move all of my current data on my macbook to the new one. Is it as simple as copying to an external, then moving it into the new macbook, or is there some weird complex process required?

  • Config "look-alike" desktop for testing purposes... small problem...

    my experiment requires me to make AWN resemble the Win7 menu bar.  My problem is that I can't seem to find the right clock/calendar applet (or configuration of such) to sincerely mimic the one from Win7... could someone shed some light on how I can p

  • USB and AirPort Extreme

    Does anybody know if taking out a USB hard drive from a Airport Extreme causes any problems. I have taken a USB stick out and didn't know if I was hurting the Stick because I didn't eject it. Thanks

  • ORA-04031 Errors

    So I am running Oracle 11g and APEX 4.2.1.00.08 on an Amazon m1.medium instance. I also have it running on a Dell T300 server locally. I haven't had any issues with application on the local server, but I keep getting memory errors on the Amazon one.

  • What is the maximum number of movies in iTunes?

    Hi iTunes People, I have 4073 entries in my iTunes MOVIES library.  I cannot add any more titles to the library.  Is there a maximum number of movies allowed in the iTunes movie database - or what?  This is not a disk space issue - it is specifically