shell script question



Hi,

I have written a shell script that is supposed to print column names in
each table in each database in a Sybase SQL Server, but for some reason
unknown to me, it failes to print information on columns. sp_help is system
stored procedure in Sybase SQL Server, which shall print the required
information. I can also get the same info from syscolumns, but sp_help
print-out is quite nice and I prefer that. I do appreciate, if somebody tell
me why does function columns () failes to print the output of sp_help.

Best regards,
Mohsen

============================================================================
============================

#!/bin/sh

# Get the name of databases
function dbList ()
{
/usr/bin/isql -Usa -P << EOF
use master
go
select name from sysdatabases order by name
go
EOF
}

# Print the tablenames in each database
function tableList ()
{
/usr/bin/isql -Usa -P << EOF
select name from ${1}.dbo.sysobjects where type = "U" order by name
go
EOF
}

# Print the property of columns
function columns ()
{
/usr/bin/isql -Usa -P << EOF
sp_help ${1}.dbo.${2}
go
EOF
}

# Get a list of databases in SQL server
dl=`dbList|egrep -v '(name|--|affected)'`

# Go through the database list and generate a list of tables within the
database
for dn in $ $dl
do
# Get a list of tables within the database
tl=`tableList $dn|egrep -v '(name|--|affected)'`

# Go through the list of tables
for tn in $tl
do
echo
echo
"---------------------------------------------------------------------------
------------------------------------------"
echo "$dn -- > $tn"
echo
"---------------------------------------------------------------------------
------------------------------------------"
# Generate data on the columns in the tables
cl=`columns $dn $tn`
echo $cl
echo
"===========================================================================
=========================="
echo
done
done


.



Relevant Pages

  • Re: File size warning
    ... they tell you to buy SQL server? ... for more than 70% of enterprise database needs, and in most cases, SQL Server ... @echo off ... I'm not sure whether the program allows compaction to be run from the ...
    (microsoft.public.win2000.general)
  • Re: [PHP] peer review (was php framework vs just php?)
    ... the database. ... Additional arguements may be supplied to indicate columns to ... echo "<input ... single quotes in the Type column of the ...
    (php.general)
  • Re: shell script question
    ... each table in each database in a Sybase SQL Server, ... me why does function columns failes to print the output of sp_help. ...
    (comp.unix.shell)
  • Re: [PHP] peer review (was php framework vs just php?)
    ... function formCreate($database, $table, $action, $excludeCols, ... the database. ... Additional arguements may be supplied to indicate columns to ... echo "<input ...
    (php.general)
  • Re: shell script question
    ... each table in each database in a Sybase SQL Server, ... me why does function columns failes to print the output of sp_help. ...
    (comp.unix.shell)

Loading