I want to run a command line utility and return the results. I'm pretty sure
I
know how to do that. What's the best practice for looping through the results
to find specific information from the results of the command line?
Say I want to search for a string "computername" in each returned row.
Thanks.
On Fri, 20 Jul 2007 10:32:05 -0700, Joe
<Joe@.discussions.microsoft.com> wrote:
>I want to run a command line utility and return the results. I'm pretty sure
>I
>know how to do that. What's the best practice for looping through the results
>to find specific information from the results of the command line?
>Say I want to search for a string "computername" in each returned row.
>Thanks.
There are diverse and contradictory way to interpret your question.
One would be that you want to run SQL Server commands from the command
prompt (sometimes called the DOS prompt). OSQL would let you run the
commands, and it is common to save the results to a .txt file. It is
possible to search a .txt file using the command line utility FIND.
Another interpretation of your question is that you intend to run
something from within SQL Server using xp_cmdshell and wish to search
the results. The approach in that case is to create a table with one
column (varchar(255) and then:
INSERT ThatTable (ThatColumn)
EXEC master..xp_cmdshell 'some command here'
After which you can search the table using SELECT and LIKE. If the
sequence of the rows is significant, include an IDENTITY column in the
table definition so that you can tell which order the rows came in.
A third interpreation could be that your question has nothing to do
with SQL Server and belongs somewhere else.
Perhaps you would like to clarify?
Roy Harvey
Beacon Falls, CT
|||Roy,
Thank you, and sorry for being unclear. The second answer is what I was
planning
and how I will do it. I just wasnt sure if I ran xp_cmdshell if I could
just loop
through the results without having to populate a table.
Thanks again.
"Roy Harvey" wrote:
> On Fri, 20 Jul 2007 10:32:05 -0700, Joe
> <Joe@.discussions.microsoft.com> wrote:
>
> There are diverse and contradictory way to interpret your question.
> One would be that you want to run SQL Server commands from the command
> prompt (sometimes called the DOS prompt). OSQL would let you run the
> commands, and it is common to save the results to a .txt file. It is
> possible to search a .txt file using the command line utility FIND.
> Another interpretation of your question is that you intend to run
> something from within SQL Server using xp_cmdshell and wish to search
> the results. The approach in that case is to create a table with one
> column (varchar(255) and then:
> INSERT ThatTable (ThatColumn)
> EXEC master..xp_cmdshell 'some command here'
> After which you can search the table using SELECT and LIKE. If the
> sequence of the rows is significant, include an IDENTITY column in the
> table definition so that you can tell which order the rows came in.
> A third interpreation could be that your question has nothing to do
> with SQL Server and belongs somewhere else.
> Perhaps you would like to clarify?
> Roy Harvey
> Beacon Falls, CT
>
Showing posts with label practice. Show all posts
Showing posts with label practice. Show all posts
Monday, March 26, 2012
Looping through Command Line Results...
I want to run a command line utility and return the results. I'm pretty sur
e
I
know how to do that. What's the best practice for looping through the resul
ts
to find specific information from the results of the command line?
Say I want to search for a string "computername" in each returned row.
Thanks.On Fri, 20 Jul 2007 10:32:05 -0700, Joe
<Joe@.discussions.microsoft.com> wrote:
>I want to run a command line utility and return the results. I'm pretty su
re
>I
>know how to do that. What's the best practice for looping through the resu
lts
>to find specific information from the results of the command line?
>Say I want to search for a string "computername" in each returned row.
>Thanks.
There are diverse and contradictory way to interpret your question.
One would be that you want to run SQL Server commands from the command
prompt (sometimes called the DOS prompt). OSQL would let you run the
commands, and it is common to save the results to a .txt file. It is
possible to search a .txt file using the command line utility FIND.
Another interpretation of your question is that you intend to run
something from within SQL Server using xp_cmdshell and wish to search
the results. The approach in that case is to create a table with one
column (varchar(255) and then:
INSERT ThatTable (ThatColumn)
EXEC master..xp_cmdshell 'some command here'
After which you can search the table using SELECT and LIKE. If the
sequence of the rows is significant, include an IDENTITY column in the
table definition so that you can tell which order the rows came in.
A third interpreation could be that your question has nothing to do
with SQL Server and belongs somewhere else.
Perhaps you would like to clarify?
Roy Harvey
Beacon Falls, CT|||Roy,
Thank you, and sorry for being unclear. The second answer is what I was
planning
and how I will do it. I just wasnt sure if I ran xp_cmdshell if I could
just loop
through the results without having to populate a table.
Thanks again.
"Roy Harvey" wrote:
> On Fri, 20 Jul 2007 10:32:05 -0700, Joe
> <Joe@.discussions.microsoft.com> wrote:
>
> There are diverse and contradictory way to interpret your question.
> One would be that you want to run SQL Server commands from the command
> prompt (sometimes called the DOS prompt). OSQL would let you run the
> commands, and it is common to save the results to a .txt file. It is
> possible to search a .txt file using the command line utility FIND.
> Another interpretation of your question is that you intend to run
> something from within SQL Server using xp_cmdshell and wish to search
> the results. The approach in that case is to create a table with one
> column (varchar(255) and then:
> INSERT ThatTable (ThatColumn)
> EXEC master..xp_cmdshell 'some command here'
> After which you can search the table using SELECT and LIKE. If the
> sequence of the rows is significant, include an IDENTITY column in the
> table definition so that you can tell which order the rows came in.
> A third interpreation could be that your question has nothing to do
> with SQL Server and belongs somewhere else.
> Perhaps you would like to clarify?
> Roy Harvey
> Beacon Falls, CT
>
e
I
know how to do that. What's the best practice for looping through the resul
ts
to find specific information from the results of the command line?
Say I want to search for a string "computername" in each returned row.
Thanks.On Fri, 20 Jul 2007 10:32:05 -0700, Joe
<Joe@.discussions.microsoft.com> wrote:
>I want to run a command line utility and return the results. I'm pretty su
re
>I
>know how to do that. What's the best practice for looping through the resu
lts
>to find specific information from the results of the command line?
>Say I want to search for a string "computername" in each returned row.
>Thanks.
There are diverse and contradictory way to interpret your question.
One would be that you want to run SQL Server commands from the command
prompt (sometimes called the DOS prompt). OSQL would let you run the
commands, and it is common to save the results to a .txt file. It is
possible to search a .txt file using the command line utility FIND.
Another interpretation of your question is that you intend to run
something from within SQL Server using xp_cmdshell and wish to search
the results. The approach in that case is to create a table with one
column (varchar(255) and then:
INSERT ThatTable (ThatColumn)
EXEC master..xp_cmdshell 'some command here'
After which you can search the table using SELECT and LIKE. If the
sequence of the rows is significant, include an IDENTITY column in the
table definition so that you can tell which order the rows came in.
A third interpreation could be that your question has nothing to do
with SQL Server and belongs somewhere else.
Perhaps you would like to clarify?
Roy Harvey
Beacon Falls, CT|||Roy,
Thank you, and sorry for being unclear. The second answer is what I was
planning
and how I will do it. I just wasnt sure if I ran xp_cmdshell if I could
just loop
through the results without having to populate a table.
Thanks again.
"Roy Harvey" wrote:
> On Fri, 20 Jul 2007 10:32:05 -0700, Joe
> <Joe@.discussions.microsoft.com> wrote:
>
> There are diverse and contradictory way to interpret your question.
> One would be that you want to run SQL Server commands from the command
> prompt (sometimes called the DOS prompt). OSQL would let you run the
> commands, and it is common to save the results to a .txt file. It is
> possible to search a .txt file using the command line utility FIND.
> Another interpretation of your question is that you intend to run
> something from within SQL Server using xp_cmdshell and wish to search
> the results. The approach in that case is to create a table with one
> column (varchar(255) and then:
> INSERT ThatTable (ThatColumn)
> EXEC master..xp_cmdshell 'some command here'
> After which you can search the table using SELECT and LIKE. If the
> sequence of the rows is significant, include an IDENTITY column in the
> table definition so that you can tell which order the rows came in.
> A third interpreation could be that your question has nothing to do
> with SQL Server and belongs somewhere else.
> Perhaps you would like to clarify?
> Roy Harvey
> Beacon Falls, CT
>
Looping through Command Line Results...
I want to run a command line utility and return the results. I'm pretty sure
I
know how to do that. What's the best practice for looping through the results
to find specific information from the results of the command line?
Say I want to search for a string "computername" in each returned row.
Thanks.On Fri, 20 Jul 2007 10:32:05 -0700, Joe
<Joe@.discussions.microsoft.com> wrote:
>I want to run a command line utility and return the results. I'm pretty sure
>I
>know how to do that. What's the best practice for looping through the results
>to find specific information from the results of the command line?
>Say I want to search for a string "computername" in each returned row.
>Thanks.
There are diverse and contradictory way to interpret your question.
One would be that you want to run SQL Server commands from the command
prompt (sometimes called the DOS prompt). OSQL would let you run the
commands, and it is common to save the results to a .txt file. It is
possible to search a .txt file using the command line utility FIND.
Another interpretation of your question is that you intend to run
something from within SQL Server using xp_cmdshell and wish to search
the results. The approach in that case is to create a table with one
column (varchar(255) and then:
INSERT ThatTable (ThatColumn)
EXEC master..xp_cmdshell 'some command here'
After which you can search the table using SELECT and LIKE. If the
sequence of the rows is significant, include an IDENTITY column in the
table definition so that you can tell which order the rows came in.
A third interpreation could be that your question has nothing to do
with SQL Server and belongs somewhere else.
Perhaps you would like to clarify?
Roy Harvey
Beacon Falls, CT|||Roy,
Thank you, and sorry for being unclear. The second answer is what I was
planning
and how I will do it. I just wasnt sure if I ran xp_cmdshell if I could
just loop
through the results without having to populate a table.
Thanks again.
"Roy Harvey" wrote:
> On Fri, 20 Jul 2007 10:32:05 -0700, Joe
> <Joe@.discussions.microsoft.com> wrote:
> >I want to run a command line utility and return the results. I'm pretty sure
> >I
> >know how to do that. What's the best practice for looping through the results
> >to find specific information from the results of the command line?
> >
> >Say I want to search for a string "computername" in each returned row.
> >
> >Thanks.
> There are diverse and contradictory way to interpret your question.
> One would be that you want to run SQL Server commands from the command
> prompt (sometimes called the DOS prompt). OSQL would let you run the
> commands, and it is common to save the results to a .txt file. It is
> possible to search a .txt file using the command line utility FIND.
> Another interpretation of your question is that you intend to run
> something from within SQL Server using xp_cmdshell and wish to search
> the results. The approach in that case is to create a table with one
> column (varchar(255) and then:
> INSERT ThatTable (ThatColumn)
> EXEC master..xp_cmdshell 'some command here'
> After which you can search the table using SELECT and LIKE. If the
> sequence of the rows is significant, include an IDENTITY column in the
> table definition so that you can tell which order the rows came in.
> A third interpreation could be that your question has nothing to do
> with SQL Server and belongs somewhere else.
> Perhaps you would like to clarify?
> Roy Harvey
> Beacon Falls, CT
>sql
I
know how to do that. What's the best practice for looping through the results
to find specific information from the results of the command line?
Say I want to search for a string "computername" in each returned row.
Thanks.On Fri, 20 Jul 2007 10:32:05 -0700, Joe
<Joe@.discussions.microsoft.com> wrote:
>I want to run a command line utility and return the results. I'm pretty sure
>I
>know how to do that. What's the best practice for looping through the results
>to find specific information from the results of the command line?
>Say I want to search for a string "computername" in each returned row.
>Thanks.
There are diverse and contradictory way to interpret your question.
One would be that you want to run SQL Server commands from the command
prompt (sometimes called the DOS prompt). OSQL would let you run the
commands, and it is common to save the results to a .txt file. It is
possible to search a .txt file using the command line utility FIND.
Another interpretation of your question is that you intend to run
something from within SQL Server using xp_cmdshell and wish to search
the results. The approach in that case is to create a table with one
column (varchar(255) and then:
INSERT ThatTable (ThatColumn)
EXEC master..xp_cmdshell 'some command here'
After which you can search the table using SELECT and LIKE. If the
sequence of the rows is significant, include an IDENTITY column in the
table definition so that you can tell which order the rows came in.
A third interpreation could be that your question has nothing to do
with SQL Server and belongs somewhere else.
Perhaps you would like to clarify?
Roy Harvey
Beacon Falls, CT|||Roy,
Thank you, and sorry for being unclear. The second answer is what I was
planning
and how I will do it. I just wasnt sure if I ran xp_cmdshell if I could
just loop
through the results without having to populate a table.
Thanks again.
"Roy Harvey" wrote:
> On Fri, 20 Jul 2007 10:32:05 -0700, Joe
> <Joe@.discussions.microsoft.com> wrote:
> >I want to run a command line utility and return the results. I'm pretty sure
> >I
> >know how to do that. What's the best practice for looping through the results
> >to find specific information from the results of the command line?
> >
> >Say I want to search for a string "computername" in each returned row.
> >
> >Thanks.
> There are diverse and contradictory way to interpret your question.
> One would be that you want to run SQL Server commands from the command
> prompt (sometimes called the DOS prompt). OSQL would let you run the
> commands, and it is common to save the results to a .txt file. It is
> possible to search a .txt file using the command line utility FIND.
> Another interpretation of your question is that you intend to run
> something from within SQL Server using xp_cmdshell and wish to search
> the results. The approach in that case is to create a table with one
> column (varchar(255) and then:
> INSERT ThatTable (ThatColumn)
> EXEC master..xp_cmdshell 'some command here'
> After which you can search the table using SELECT and LIKE. If the
> sequence of the rows is significant, include an IDENTITY column in the
> table definition so that you can tell which order the rows came in.
> A third interpreation could be that your question has nothing to do
> with SQL Server and belongs somewhere else.
> Perhaps you would like to clarify?
> Roy Harvey
> Beacon Falls, CT
>sql
Monday, March 12, 2012
lookup table relationships best practice
What is the best way to setup relationships between one lookup table
and many other tables. The tables did not have any lookup table
relationships which I am adding. One lookup table is used for same data
in several different places.
and many other tables. The tables did not have any lookup table
relationships which I am adding. One lookup table is used for same data
in several different places.
To use one lookup tables with several tables, I had to disable "Cascade
Update" and only have "enforce relationships for updates and inserts"
checked.
Any pros/cons?
Thanks in advance.
P"Lookup table" doesn't mean anything in a relational database. There is only
one type of table.
You define relationships between tables with a foreign key. Unfortunately
SQL Server will only allow cascaded updates and deletes on one key per
table. However, in many cases cascaded updates are undesirable and since
it's fairly easy to code the same you probably won't miss this feature most
of the time.
--
David Portas
SQL Server MVP
--
Subscribe to:
Posts (Atom)