Declare @.pTable varchar(30)
DECLARE @.TotRec integer
select @.pTable = 'Salaires'
SELECT @.TotRec EXEC ('SELECT Count(*) FROM ' + @.pTable)
GO
Print @.TotRec
How can I insert the results from an EXEC command?[QUOTE][SIZE=1]Originally posted by ericjean
Declare @.pTable varchar(30)
DECLARE @.TotRec integer
select @.pTable = 'Salaires'
SELECT @.TotRec = EXEC ('SELECT Count(*) FROM ' + @.pTable)
GO
Print @.TotRec
Like that is not correct!|||Unless you are just presenting a simplified example, there is no need to use dynamic sql to get rowcounts. You can look them up directly in the system tables (sysindexes where indid in (0, 1)):
-------------
set @.TotRec =
(select sysindexes.Rowcnt
from sysobjects
inner join sysindexes on sysobjects.id = sysindexes.id
where sysobjects.name = @.pTable and sysobjects.xtype = 'U' and sysindexes.indid in (0, 1)
Print @.TotRec
-------------
blindman|||Good idea!
Thank's|||I need to do like this
Declare @.pTable varchar(30)
DECLARE @.tmp integer
select @.pTable = 'Salaires'
SELECT @.tmp = exec('SELECT count(*) FROM ' + @.pTable + ' WHERE ID = 2)|||Declare @.pTable varchar(30)
DECLARE @.tmp integer
select @.pTable = 'Salaires'
SET @.tmp = ('SELECT count(*) FROM ' + @.pTable + ' WHERE ID = 2)
@.tmp now has the count of that table
Showing posts with label exec. Show all posts
Showing posts with label exec. Show all posts
Friday, March 9, 2012
Monday, February 27, 2012
How can I get the result of SP_Help myTable
Hi,
Since "Sp_help myTable" will give different rows of result, so I could not
run like
"insert into aTable exec sp_help myTable" to get the result of sp_help for
analysing. How could I get the result and analysing it?
And also, I remember that in the past, I could check the code of sp_help to
get some help for doing the same task that sp_help does, but now, I could
not find the definition of sp_help.
Thanks for any advice
Frank
Hi Frank
The definitions of the system stored procedures are all available in the
master database and can be viewed using sp_helptext.
USE master
EXEC sp_helptext sp_help
Since sp_help returns multiple results sets, it will be difficult to put the
results all into one table.
You could take the code of sp_help and create a new proc that takes each
result set and puts it into a separate table.
HTH
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Frank" <wangping@.lucent.com> wrote in message
news:Obn7NgwPFHA.2652@.TK2MSFTNGP10.phx.gbl...
> Hi,
> Since "Sp_help myTable" will give different rows of result, so I could not
> run like
> "insert into aTable exec sp_help myTable" to get the result of sp_help for
> analysing. How could I get the result and analysing it?
> And also, I remember that in the past, I could check the code of sp_help
> to
> get some help for doing the same task that sp_help does, but now, I could
> not find the definition of sp_help.
> Thanks for any advice
> Frank
>
|||Thanks Kalen,
That's what I want.
B/R
Frank
"Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
news:ehcxCjwPFHA.1172@.TK2MSFTNGP12.phx.gbl...
> Hi Frank
> The definitions of the system stored procedures are all available in the
> master database and can be viewed using sp_helptext.
>
> USE master
> EXEC sp_helptext sp_help
> Since sp_help returns multiple results sets, it will be difficult to put
the[vbcol=seagreen]
> results all into one table.
> You could take the code of sp_help and create a new proc that takes each
> result set and puts it into a separate table.
> --
> HTH
> --
> Kalen Delaney
> SQL Server MVP
> www.SolidQualityLearning.com
>
> "Frank" <wangping@.lucent.com> wrote in message
> news:Obn7NgwPFHA.2652@.TK2MSFTNGP10.phx.gbl...
not[vbcol=seagreen]
for[vbcol=seagreen]
could
>
Since "Sp_help myTable" will give different rows of result, so I could not
run like
"insert into aTable exec sp_help myTable" to get the result of sp_help for
analysing. How could I get the result and analysing it?
And also, I remember that in the past, I could check the code of sp_help to
get some help for doing the same task that sp_help does, but now, I could
not find the definition of sp_help.
Thanks for any advice
Frank
Hi Frank
The definitions of the system stored procedures are all available in the
master database and can be viewed using sp_helptext.
USE master
EXEC sp_helptext sp_help
Since sp_help returns multiple results sets, it will be difficult to put the
results all into one table.
You could take the code of sp_help and create a new proc that takes each
result set and puts it into a separate table.
HTH
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Frank" <wangping@.lucent.com> wrote in message
news:Obn7NgwPFHA.2652@.TK2MSFTNGP10.phx.gbl...
> Hi,
> Since "Sp_help myTable" will give different rows of result, so I could not
> run like
> "insert into aTable exec sp_help myTable" to get the result of sp_help for
> analysing. How could I get the result and analysing it?
> And also, I remember that in the past, I could check the code of sp_help
> to
> get some help for doing the same task that sp_help does, but now, I could
> not find the definition of sp_help.
> Thanks for any advice
> Frank
>
|||Thanks Kalen,
That's what I want.
B/R
Frank
"Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
news:ehcxCjwPFHA.1172@.TK2MSFTNGP12.phx.gbl...
> Hi Frank
> The definitions of the system stored procedures are all available in the
> master database and can be viewed using sp_helptext.
>
> USE master
> EXEC sp_helptext sp_help
> Since sp_help returns multiple results sets, it will be difficult to put
the[vbcol=seagreen]
> results all into one table.
> You could take the code of sp_help and create a new proc that takes each
> result set and puts it into a separate table.
> --
> HTH
> --
> Kalen Delaney
> SQL Server MVP
> www.SolidQualityLearning.com
>
> "Frank" <wangping@.lucent.com> wrote in message
> news:Obn7NgwPFHA.2652@.TK2MSFTNGP10.phx.gbl...
not[vbcol=seagreen]
for[vbcol=seagreen]
could
>
How can I get the result of SP_Help myTable
Hi,
Since "Sp_help myTable" will give different rows of result, so I could not
run like
"insert into aTable exec sp_help myTable" to get the result of sp_help for
analysing. How could I get the result and analysing it?
And also, I remember that in the past, I could check the code of sp_help to
get some help for doing the same task that sp_help does, but now, I could
not find the definition of sp_help.
Thanks for any advice
FrankHi Frank
The definitions of the system stored procedures are all available in the
master database and can be viewed using sp_helptext.
USE master
EXEC sp_helptext sp_help
Since sp_help returns multiple results sets, it will be difficult to put the
results all into one table.
You could take the code of sp_help and create a new proc that takes each
result set and puts it into a separate table.
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Frank" <wangping@.lucent.com> wrote in message
news:Obn7NgwPFHA.2652@.TK2MSFTNGP10.phx.gbl...
> Hi,
> Since "Sp_help myTable" will give different rows of result, so I could not
> run like
> "insert into aTable exec sp_help myTable" to get the result of sp_help for
> analysing. How could I get the result and analysing it?
> And also, I remember that in the past, I could check the code of sp_help
> to
> get some help for doing the same task that sp_help does, but now, I could
> not find the definition of sp_help.
> Thanks for any advice
> Frank
>|||Thanks Kalen,
That's what I want.
B/R
Frank
"Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
news:ehcxCjwPFHA.1172@.TK2MSFTNGP12.phx.gbl...
> Hi Frank
> The definitions of the system stored procedures are all available in the
> master database and can be viewed using sp_helptext.
>
> USE master
> EXEC sp_helptext sp_help
> Since sp_help returns multiple results sets, it will be difficult to put
the
> results all into one table.
> You could take the code of sp_help and create a new proc that takes each
> result set and puts it into a separate table.
> --
> HTH
> --
> Kalen Delaney
> SQL Server MVP
> www.SolidQualityLearning.com
>
> "Frank" <wangping@.lucent.com> wrote in message
> news:Obn7NgwPFHA.2652@.TK2MSFTNGP10.phx.gbl...
not[vbcol=seagreen]
for[vbcol=seagreen]
could[vbcol=seagreen]
>
Since "Sp_help myTable" will give different rows of result, so I could not
run like
"insert into aTable exec sp_help myTable" to get the result of sp_help for
analysing. How could I get the result and analysing it?
And also, I remember that in the past, I could check the code of sp_help to
get some help for doing the same task that sp_help does, but now, I could
not find the definition of sp_help.
Thanks for any advice
FrankHi Frank
The definitions of the system stored procedures are all available in the
master database and can be viewed using sp_helptext.
USE master
EXEC sp_helptext sp_help
Since sp_help returns multiple results sets, it will be difficult to put the
results all into one table.
You could take the code of sp_help and create a new proc that takes each
result set and puts it into a separate table.
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Frank" <wangping@.lucent.com> wrote in message
news:Obn7NgwPFHA.2652@.TK2MSFTNGP10.phx.gbl...
> Hi,
> Since "Sp_help myTable" will give different rows of result, so I could not
> run like
> "insert into aTable exec sp_help myTable" to get the result of sp_help for
> analysing. How could I get the result and analysing it?
> And also, I remember that in the past, I could check the code of sp_help
> to
> get some help for doing the same task that sp_help does, but now, I could
> not find the definition of sp_help.
> Thanks for any advice
> Frank
>|||Thanks Kalen,
That's what I want.
B/R
Frank
"Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
news:ehcxCjwPFHA.1172@.TK2MSFTNGP12.phx.gbl...
> Hi Frank
> The definitions of the system stored procedures are all available in the
> master database and can be viewed using sp_helptext.
>
> USE master
> EXEC sp_helptext sp_help
> Since sp_help returns multiple results sets, it will be difficult to put
the
> results all into one table.
> You could take the code of sp_help and create a new proc that takes each
> result set and puts it into a separate table.
> --
> HTH
> --
> Kalen Delaney
> SQL Server MVP
> www.SolidQualityLearning.com
>
> "Frank" <wangping@.lucent.com> wrote in message
> news:Obn7NgwPFHA.2652@.TK2MSFTNGP10.phx.gbl...
not[vbcol=seagreen]
for[vbcol=seagreen]
could[vbcol=seagreen]
>
How can I get the result of SP_Help myTable
Hi,
Since "Sp_help myTable" will give different rows of result, so I could not
run like
"insert into aTable exec sp_help myTable" to get the result of sp_help for
analysing. How could I get the result and analysing it?
And also, I remember that in the past, I could check the code of sp_help to
get some help for doing the same task that sp_help does, but now, I could
not find the definition of sp_help.
Thanks for any advice
FrankHi Frank
The definitions of the system stored procedures are all available in the
master database and can be viewed using sp_helptext.
USE master
EXEC sp_helptext sp_help
Since sp_help returns multiple results sets, it will be difficult to put the
results all into one table.
You could take the code of sp_help and create a new proc that takes each
result set and puts it into a separate table.
--
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Frank" <wangping@.lucent.com> wrote in message
news:Obn7NgwPFHA.2652@.TK2MSFTNGP10.phx.gbl...
> Hi,
> Since "Sp_help myTable" will give different rows of result, so I could not
> run like
> "insert into aTable exec sp_help myTable" to get the result of sp_help for
> analysing. How could I get the result and analysing it?
> And also, I remember that in the past, I could check the code of sp_help
> to
> get some help for doing the same task that sp_help does, but now, I could
> not find the definition of sp_help.
> Thanks for any advice
> Frank
>|||Thanks Kalen,
That's what I want.
B/R
Frank
"Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
news:ehcxCjwPFHA.1172@.TK2MSFTNGP12.phx.gbl...
> Hi Frank
> The definitions of the system stored procedures are all available in the
> master database and can be viewed using sp_helptext.
>
> USE master
> EXEC sp_helptext sp_help
> Since sp_help returns multiple results sets, it will be difficult to put
the
> results all into one table.
> You could take the code of sp_help and create a new proc that takes each
> result set and puts it into a separate table.
> --
> HTH
> --
> Kalen Delaney
> SQL Server MVP
> www.SolidQualityLearning.com
>
> "Frank" <wangping@.lucent.com> wrote in message
> news:Obn7NgwPFHA.2652@.TK2MSFTNGP10.phx.gbl...
> > Hi,
> >
> > Since "Sp_help myTable" will give different rows of result, so I could
not
> > run like
> > "insert into aTable exec sp_help myTable" to get the result of sp_help
for
> > analysing. How could I get the result and analysing it?
> >
> > And also, I remember that in the past, I could check the code of sp_help
> > to
> > get some help for doing the same task that sp_help does, but now, I
could
> > not find the definition of sp_help.
> >
> > Thanks for any advice
> > Frank
> >
> >
>
Since "Sp_help myTable" will give different rows of result, so I could not
run like
"insert into aTable exec sp_help myTable" to get the result of sp_help for
analysing. How could I get the result and analysing it?
And also, I remember that in the past, I could check the code of sp_help to
get some help for doing the same task that sp_help does, but now, I could
not find the definition of sp_help.
Thanks for any advice
FrankHi Frank
The definitions of the system stored procedures are all available in the
master database and can be viewed using sp_helptext.
USE master
EXEC sp_helptext sp_help
Since sp_help returns multiple results sets, it will be difficult to put the
results all into one table.
You could take the code of sp_help and create a new proc that takes each
result set and puts it into a separate table.
--
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Frank" <wangping@.lucent.com> wrote in message
news:Obn7NgwPFHA.2652@.TK2MSFTNGP10.phx.gbl...
> Hi,
> Since "Sp_help myTable" will give different rows of result, so I could not
> run like
> "insert into aTable exec sp_help myTable" to get the result of sp_help for
> analysing. How could I get the result and analysing it?
> And also, I remember that in the past, I could check the code of sp_help
> to
> get some help for doing the same task that sp_help does, but now, I could
> not find the definition of sp_help.
> Thanks for any advice
> Frank
>|||Thanks Kalen,
That's what I want.
B/R
Frank
"Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
news:ehcxCjwPFHA.1172@.TK2MSFTNGP12.phx.gbl...
> Hi Frank
> The definitions of the system stored procedures are all available in the
> master database and can be viewed using sp_helptext.
>
> USE master
> EXEC sp_helptext sp_help
> Since sp_help returns multiple results sets, it will be difficult to put
the
> results all into one table.
> You could take the code of sp_help and create a new proc that takes each
> result set and puts it into a separate table.
> --
> HTH
> --
> Kalen Delaney
> SQL Server MVP
> www.SolidQualityLearning.com
>
> "Frank" <wangping@.lucent.com> wrote in message
> news:Obn7NgwPFHA.2652@.TK2MSFTNGP10.phx.gbl...
> > Hi,
> >
> > Since "Sp_help myTable" will give different rows of result, so I could
not
> > run like
> > "insert into aTable exec sp_help myTable" to get the result of sp_help
for
> > analysing. How could I get the result and analysing it?
> >
> > And also, I remember that in the past, I could check the code of sp_help
> > to
> > get some help for doing the same task that sp_help does, but now, I
could
> > not find the definition of sp_help.
> >
> > Thanks for any advice
> > Frank
> >
> >
>
Subscribe to:
Posts (Atom)