|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Is this an inline sql statement or a stored procedure?
-- Jack Vamvas ___________________________________ Search IT jobs from multiple sources- http://www.ITjobfeed.com <eeb4u@hotmail.com> wrote in message news:0d9a69ed-bf9f-4ad1-b215-99e2c7d6d559@k2g2000hse.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 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Jan 11, 11:29 am, "Jack Vamvas" <DEL_TO_RE...@del.com> wrote:
> Is this an inline sql statement or a stored procedure? > > -- > > Jack Vamvas > ___________________________________ > Search IT jobs from multiple sources- http://www.ITjobfeed.com > > <ee...@hotmail.com> wrote in message > > news:0d9a69ed-bf9f-4ad1-b215-99e2c7d6d559@k2g2000hse.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 |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Jan 11, 12:06 pm, "ee...@hotmail.com" <ee...@hotmail.com> wrote:
> On Jan 11, 11:29 am, "Jack Vamvas" <DEL_TO_RE...@del.com> wrote: > > > > > Is this an inline sql statement or a stored procedure? > > > -- > > > Jack Vamvas > > ___________________________________ > > Search IT jobs from multiple sources- http://www.ITjobfeed.com > > > <ee...@hotmail.com> wrote in message > > >news:0d9a69ed-bf9f-4ad1-b215-99e2c7d6d559@k2g2000hse.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. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Have you solved this one?
-- Jack Vamvas ___________________________________ Search IT jobs from multiple sources- http://www.ITjobfeed.com <eeb4u@hotmail.com> wrote in message news:971edef6-3d44-48ad-adac-d1f39ef63d52@i7g2000prf.googlegroups.com... > On Jan 11, 12:06 pm, "ee...@hotmail.com" <ee...@hotmail.com> wrote: >> On Jan 11, 11:29 am, "Jack Vamvas" <DEL_TO_RE...@del.com> wrote: >> >> >> >> > Is this an inline sql statement or a stored procedure? >> >> > -- >> >> > Jack Vamvas >> > ___________________________________ >> > Search IT jobs from multiple sources- http://www.ITjobfeed.com >> >> > <ee...@hotmail.com> wrote in message >> >> >news:0d9a69ed-bf9f-4ad1-b215-99e2c7d6d559@k2g2000hse.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. |
|
![]() |
| Outils de la discussion | |
|
|