Sponsored Content
Top Forums Shell Programming and Scripting how to Connect from ksh script to SQL server Post 302721277 by santoshhegde on Thursday 25th of October 2012 09:37:12 AM
Old 10-25-2012
I want to do something like below actually this below code is for Oracle DB I want it for SQL server:

Code:
#! /bin/ksh
# @(#)$Header: test_data.ksh

DATA_DIRECTORY="C:\jobs\data"
DBNAME=$1
SCHEMA=$2
PASSWD=$3
CONN1="${SCHEMA}/${PASSWD}@${DBNAME}"

ORACLE_SID=${DBNAME}
export ORAENV_ASK=NO

ZIP_FILE=`ls -lt ${DATA_DIRECTORY}/test_*.zip| awk '{if (substr($1,1,1) == "-" && n++ < 1) print $9}'`
ZIP_CONTENT=`basename ${ZIP_FILE}| awk '{print substr($1,1,10)}'`
unzip -o ${ZIP_FILE} -d ${DATA_DIRECTORY}
mv ${DATA_DIRECTORY}/${ZIP_CONTENT} ${DATA_DIRECTORY}/test.txt

ftp_target="test.txt"

sqlldr  ${CONN1} data="C:\jobs\data\test.txt"
    control="C:\DATA\abcd.ctl" \

Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.
 

10 More Discussions You Might Find Interesting

1. Solaris

Connect From VB to SQL Server

Dear All Now I can't connect from VB to Sybase on Unix. How could I do? Please help me. (0 Replies)
Discussion started by: Than Chanroeun
0 Replies

2. Shell Programming and Scripting

HOw to connect oracle using ksh and perl script

HI, So far i have been worked on sybase with perl and ksh scripts, i don't know how to connect using oralce, if any body could explain that is great. Thanks in advance. chendra (3 Replies)
Discussion started by: chendra.putta
3 Replies

3. Shell Programming and Scripting

connect to SQL server from shell script

Hi all, I need to connect to SQL server from shell script. Then need to execute queries from shell script. Kindly let me know on how to do this Thanks, Ananthi.U (1 Reply)
Discussion started by: ananthi_ku
1 Replies

4. Solaris

connect to SQL server from shell script

Hi all, I need to connect to SQL server from shell script. Then need to execute queries from shell script as below 1. To compare values of an array with SQL table's entry. Kindly let me know on how to do this Thanks, Double post. Continue here (0 Replies)
Discussion started by: amitbhelave
0 Replies

5. Shell Programming and Scripting

connect to SQL server from shell script

Hi all, I need to connect to SQL server from shell script. Then need to execute queries from shell script as below 1. To compare values of an array with SQL table's entry. I am using solaris-5.1 to run shell script and want to connect to SQL-5.1 which is installed on SantOS. Kindly let... (3 Replies)
Discussion started by: amitbhelave
3 Replies

6. Emergency UNIX and Linux Support

How to connect Unix and Sql Server 2005?

Hi All Can any one please help me about How to connect Unix with Sql Server 2005 I want to do it urgently and i didn't find the way. (14 Replies)
Discussion started by: parthmittal2007
14 Replies

7. SuSE

Connect to SQL server from Linux

I am trying to establish connection with SQL server 2008 through ODBC on Linux. First step would be 1. How to verify if ODBC driver for SQL server is installed on Linux OS. PLease let me know how to do it/ if there is any link which could be helpful in this context. thanks in advance (1 Reply)
Discussion started by: cvsanthosh
1 Replies

8. Shell Programming and Scripting

Connect (SSH) to Windows server via Linux server through a script and passing command.. but failing

I am trying to connect to Windows server via Linux server through a script and run two commands " cd and ls " But its giving me error saying " could not start the program" followed by the command name i specify e g : "cd" i am trying in this manner " ssh username@servername "cd... (5 Replies)
Discussion started by: sunil seelam
5 Replies

9. AIX

Connect to a SQL server from AIX

Hello aix community, After scouring the internet to find a step by step process, I've exhausted my efforts. Although I have learned a lot which brings me to this forum. I'm totally new and hope to ask the right questions. What is the easiest way to connect to a SQL server from aix? ... (2 Replies)
Discussion started by: TechStudent36
2 Replies

10. AIX

Connect to database server and execute sql

I have a requirement and below is the detail. Create a shell script and needs to run in server "a". Connect to teradata database server "b". execute the .sql file from server "a" Save the output of the query to a file in server "a" Schedule this shell script to run every day for every 4... (1 Reply)
Discussion started by: MadhuSeven
1 Replies
CREATE 
SCHEMA(7) SQL Commands CREATE SCHEMA(7) NAME
CREATE SCHEMA - define a new schema SYNOPSIS
CREATE SCHEMA schemaname [ AUTHORIZATION username ] [ schema_element [ ... ] ] CREATE SCHEMA AUTHORIZATION username [ schema_element [ ... ] ] DESCRIPTION
CREATE SCHEMA enters a new schema into the current database. The schema name must be distinct from the name of any existing schema in the current database. A schema is essentially a namespace: it contains named objects (tables, data types, functions, and operators) whose names can duplicate those of other objects existing in other schemas. Named objects are accessed either by ``qualifying'' their names with the schema name as a prefix, or by setting a search path that includes the desired schema(s). A CREATE command specifying an unqualified object name creates the object in the current schema (the one at the front of the search path, which can be determined with the function current_schema). Optionally, CREATE SCHEMA can include subcommands to create objects within the new schema. The subcommands are treated essentially the same as separate commands issued after creating the schema, except that if the AUTHORIZATION clause is used, all the created objects will be owned by that user. PARAMETERS
schemaname The name of a schema to be created. If this is omitted, the user name is used as the schema name. The name cannot begin with pg_, as such names are reserved for system schemas. username The name of the user who will own the schema. If omitted, defaults to the user executing the command. Only superusers can create schemas owned by users other than themselves. schema_element An SQL statement defining an object to be created within the schema. Currently, only CREATE TABLE, CREATE VIEW, CREATE INDEX, CREATE SEQUENCE, CREATE TRIGGER and GRANT are accepted as clauses within CREATE SCHEMA. Other kinds of objects may be created in separate commands after the schema is created. NOTES
To create a schema, the invoking user must have the CREATE privilege for the current database. (Of course, superusers bypass this check.) EXAMPLES
Create a schema: CREATE SCHEMA myschema; Create a schema for user joe; the schema will also be named joe: CREATE SCHEMA AUTHORIZATION joe; Create a schema and create a table and view within it: CREATE SCHEMA hollywood CREATE TABLE films (title text, release date, awards text[]) CREATE VIEW winners AS SELECT title, release FROM films WHERE awards IS NOT NULL; Notice that the individual subcommands do not end with semicolons. The following is an equivalent way of accomplishing the same result: CREATE SCHEMA hollywood; CREATE TABLE hollywood.films (title text, release date, awards text[]); CREATE VIEW hollywood.winners AS SELECT title, release FROM hollywood.films WHERE awards IS NOT NULL; COMPATIBILITY
The SQL standard allows a DEFAULT CHARACTER SET clause in CREATE SCHEMA, as well as more subcommand types than are presently accepted by PostgreSQL. The SQL standard specifies that the subcommands in CREATE SCHEMA can appear in any order. The present PostgreSQL implementation does not handle all cases of forward references in subcommands; it might sometimes be necessary to reorder the subcommands in order to avoid forward references. According to the SQL standard, the owner of a schema always owns all objects within it. PostgreSQL allows schemas to contain objects owned by users other than the schema owner. This can happen only if the schema owner grants the CREATE privilege on his schema to someone else. SEE ALSO
ALTER SCHEMA [alter_schema(7)], DROP SCHEMA [drop_schema(7)] SQL - Language Statements 2010-05-14 CREATE SCHEMA(7)
All times are GMT -4. The time now is 01:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy