473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

using freetds tsql

I am connecting to MS SQL 2000 from Red Hat EL4 using freetds and
currently running queries to get counts on tables etc. When running
SELECT queries I notice that the data returns and I have to parse out
the field names etc. Is there any easier way to extract the data in a
comma separated form?

I was thinking of reading the contents into a structured file or
buffer and then getting the field names that way. However I thought I
might be over engineering a simple query script, but I haven't come up
with a simpler way yet.

Basically, I am trying to writing a script on linux that queries the
database I and with the results of that query it will create an insert
statement for another database.

Any suggestions are welcome.
Mike
Jan 11 '08 #1
4 4916
Is this an inline sql statement or a stored procedure?

--

Jack Vamvas
___________________________________
Search IT jobs from multiple sources- http://www.ITjobfeed.com


<ee***@hotmail.comwrote in message
news:0d**********************************@k2g2000h se.googlegroups.com...
>I am connecting to MS SQL 2000 from Red Hat EL4 using freetds and
currently running queries to get counts on tables etc. When running
SELECT queries I notice that the data returns and I have to parse out
the field names etc. Is there any easier way to extract the data in a
comma separated form?

I was thinking of reading the contents into a structured file or
buffer and then getting the field names that way. However I thought I
might be over engineering a simple query script, but I haven't come up
with a simpler way yet.

Basically, I am trying to writing a script on linux that queries the
database I and with the results of that query it will create an insert
statement for another database.

Any suggestions are welcome.
Mike

Jan 11 '08 #2
On Jan 11, 11:29 am, "Jack Vamvas" <DEL_TO_RE...@del.comwrote:
Is this an inline sql statement or a stored procedure?

--

Jack Vamvas
___________________________________
Search IT jobs from multiple sources- http://www.ITjobfeed.com

<ee...@hotmail.comwrote in message

news:0d**********************************@k2g2000h se.googlegroups.com...
I am connecting to MS SQL 2000 from Red Hat EL4 using freetds and
currently running queries to get counts on tables etc. When running
SELECT queries I notice that the data returns and I have to parse out
the field names etc. Is there any easier way to extract the data in a
comma separated form?
I was thinking of reading the contents into a structured file or
buffer and then getting the field names that way. However I thought I
might be over engineering a simple query script, but I haven't come up
with a simpler way yet.
Basically, I am trying to writing a script on linux that queries the
database I and with the results of that query it will create an insert
statement for another database.
Any suggestions are welcome.
Mike
This will be a simple select query that I can turn into an insert
statement via a shell script. We have several databases that are
currently replicated via GoldenGate and "once in a blue moon" it fails
to replicate the complete transactions from one of the databases to
one of the others. This has only happened twice in 6 months when our
flakey frame relay connection took a slight hit. It wasn't noticed
for sometime and therefore our goldengate trail files are gone (we
can't replay them). I wanted to add monitoring to identify table row
discrepancies between the 4 databases (which I have done) and then
create a script that will query a known good database and generate the
insert statements for the known bad database. The "monitor/insert
statement builder scripts" reside on a RHEL platform and I connect to
SQLSERVERs which are running on a Windows 2003 server. I am
connecting to SQLSERVER via tsql (the utility from freetds.org). It
returns the counts among other values from the tables, and I am able
to parse the output to identify the actual count then perform the
logic to decide which databases are out of sync. That is simple, but
when running a select statement, it returns the column headers and the
data and it is not a very straight forward task to code the correct
syntax for my inserts which obviously require quotes, comma separators
etc. I felt there must be a better way of doing this, that is,
extracting the data with field terminators at least.

Thanks,

Mike
Jan 11 '08 #3
On Jan 11, 12:06 pm, "ee...@hotmail.com" <ee...@hotmail.comwrote:
On Jan 11, 11:29 am, "Jack Vamvas" <DEL_TO_RE...@del.comwrote:
Is this an inline sql statement or a stored procedure?
--
Jack Vamvas
___________________________________
Search IT jobs from multiple sources- http://www.ITjobfeed.com
<ee...@hotmail.comwrote in message
news:0d**********************************@k2g2000h se.googlegroups.com...
>I am connecting to MS SQL 2000 from Red Hat EL4 using freetds and
currently running queries to get counts on tables etc. When running
SELECT queries I notice that the data returns and I have to parse out
the field names etc. Is there any easier way to extract the data in a
comma separated form?
I was thinking of reading the contents into a structured file or
buffer and then getting the field names that way. However I thought I
might be over engineering a simple query script, but I haven't come up
with a simpler way yet.
Basically, I am trying to writing a script on linux that queries the
database I and with the results of that query it will create an insert
statement for another database.
Any suggestions are welcome.
Mike

This will be a simple select query that I can turn into an insert
statement via a shell script. We have several databases that are
currently replicated via GoldenGate and "once in a blue moon" it fails
to replicate the complete transactions from one of the databases to
one of the others. This has only happened twice in 6 months when our
flakey frame relay connection took a slight hit. It wasn't noticed
for sometime and therefore our goldengate trail files are gone (we
can't replay them). I wanted to add monitoring to identify table row
discrepancies between the 4 databases (which I have done) and then
create a script that will query a known good database and generate the
insert statements for the known bad database. The "monitor/insert
statement builder scripts" reside on a RHEL platform and I connect to
SQLSERVERs which are running on a Windows 2003 server. I am
connecting to SQLSERVER via tsql (the utility from freetds.org). It
returns the counts among other values from the tables, and I am able
to parse the output to identify the actual count then perform the
logic to decide which databases are out of sync. That is simple, but
when running a select statement, it returns the column headers and the
data and it is not a very straight forward task to code the correct
syntax for my inserts which obviously require quotes, comma separators
etc. I felt there must be a better way of doing this, that is,
extracting the data with field terminators at least.

Thanks,

Mike
oops! result is tab delimited. Should be able to do something now.
Jan 11 '08 #4
Have you solved this one?

--

Jack Vamvas
___________________________________
Search IT jobs from multiple sources- http://www.ITjobfeed.com


<ee***@hotmail.comwrote in message
news:97**********************************@i7g2000p rf.googlegroups.com...
On Jan 11, 12:06 pm, "ee...@hotmail.com" <ee...@hotmail.comwrote:
>On Jan 11, 11:29 am, "Jack Vamvas" <DEL_TO_RE...@del.comwrote:
Is this an inline sql statement or a stored procedure?
--
Jack Vamvas
___________________________________
Search IT jobs from multiple sources- http://www.ITjobfeed.com
<ee...@hotmail.comwrote in message
>news:0d**********************************@k2g2000 hse.googlegroups.com...
>I am connecting to MS SQL 2000 from Red Hat EL4 using freetds and
currently running queries to get counts on tables etc. When running
SELECT queries I notice that the data returns and I have to parse out
the field names etc. Is there any easier way to extract the data in
a
comma separated form?
I was thinking of reading the contents into a structured file or
buffer and then getting the field names that way. However I thought
I
might be over engineering a simple query script, but I haven't come
up
with a simpler way yet.
Basically, I am trying to writing a script on linux that queries the
database I and with the results of that query it will create an
insert
statement for another database.
Any suggestions are welcome.
Mike

This will be a simple select query that I can turn into an insert
statement via a shell script. We have several databases that are
currently replicated via GoldenGate and "once in a blue moon" it fails
to replicate the complete transactions from one of the databases to
one of the others. This has only happened twice in 6 months when our
flakey frame relay connection took a slight hit. It wasn't noticed
for sometime and therefore our goldengate trail files are gone (we
can't replay them). I wanted to add monitoring to identify table row
discrepancies between the 4 databases (which I have done) and then
create a script that will query a known good database and generate the
insert statements for the known bad database. The "monitor/insert
statement builder scripts" reside on a RHEL platform and I connect to
SQLSERVERs which are running on a Windows 2003 server. I am
connecting to SQLSERVER via tsql (the utility from freetds.org). It
returns the counts among other values from the tables, and I am able
to parse the output to identify the actual count then perform the
logic to decide which databases are out of sync. That is simple, but
when running a select statement, it returns the column headers and the
data and it is not a very straight forward task to code the correct
syntax for my inserts which obviously require quotes, comma separators
etc. I felt there must be a better way of doing this, that is,
extracting the data with field terminators at least.

Thanks,

Mike

oops! result is tab delimited. Should be able to do something now.

Jan 16 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: William Holroyd | last post by:
I recently took over a web project that utilizes a MS SQL2000 server via PHP. The web server itself is screwed and so I'm trying to configure another box to act as a temporary server until i can...
18
by: mountain man | last post by:
Greetings to all database professionals and laymen, Let us make a bold assumption that we have developed a software tool for the SQL Server environment which simply acts as an interface between...
14
by: erezep | last post by:
I'm running a site balanced between 5 apache servers running on FC3, apache 2.0.53,php 4.3.4,freetds 0.63. I have this strange problem that sometimes, not even times of load, the connections...
16
by: agrawal.solutions | last post by:
Hello Friends I am asking a very silly question but i dont find any solution fo this.. I am selectiong a recordset and want to populate a combobox where id would be inviseble and the content...
13
by: Filips Benoit | last post by:
Dear All, How can I show the resultrecords of a SP. I can be done by doubleclick the SPname? But how to do it by code. I want the following interface In my form the user 1 selects a SP...
8
by: David Lozzi | last post by:
I'm fairly new to ASP.Net 2.0 SQLDatasource objects. It defaults using TSQL statments for the SELECT, INSERT, UPDATE, DELETE commands, which is great and it works. However, I've always been taught...
2
by: grezios | last post by:
Hi everybody and first of all thank you very much for your help, i am on a linux fedora core 5 server and i want to odbc connect to a windows 2003 server with MSSQL Server database. the iODBC is...
0
by: hassanali20 | last post by:
I've surfed this forum and found one thread which was talking about the same problem i've, but it didn't help in my situation. http://www.thescripts.com/forum/thread510563.html I could connect to...
3
by: ckauvar | last post by:
The PHP below calls a stored procedure in a MSSQL database when I am using SQL in a Windows environment. I've recently switched to a UNIX environment and am now using ODBC (via FreeTDS) to connect...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.