sql2k
Is there a tool that I can:
Box1 and Box2 start with exactly the same data.
Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
queries/ everything except maybe for jobs.
Run all of those activities on Box2. The goal being to make performance
adjustments and see if they do anything.
TIA, ChrisR
hI
SQL Profiler will capture database activity and you can script the output as
a SQL file. You can also use the data from profiler to feed into the Index
tuning wizard, therefore if you have a reasonable profileof the live system
you can see what it suggests.
John
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> sql2k
> Is there a tool that I can:
> Box1 and Box2 start with exactly the same data.
> Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> queries/ everything except maybe for jobs.
> Run all of those activities on Box2. The goal being to make performance
> adjustments and see if they do anything.
> TIA, ChrisR
|||Yes,
Read the help file in the SQL Profiler. There are about 6 items that you
must log in order to do this.
Rick Sawtell
MCT, MCSD, MCDBA
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> sql2k
> Is there a tool that I can:
> Box1 and Box2 start with exactly the same data.
> Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> queries/ everything except maybe for jobs.
> Run all of those activities on Box2. The goal being to make performance
> adjustments and see if they do anything.
> TIA, ChrisR
|||The help file is quite lengthy. Could you point me in the right direction?
What do I type in the Index?
"Rick Sawtell" wrote:
> Yes,
> Read the help file in the SQL Profiler. There are about 6 items that you
> must log in order to do this.
> Rick Sawtell
> MCT, MCSD, MCDBA
>
> "ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
> news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
>
>
|||I'm able to trace to a trace file and replay. But its trying to replay in
Master. I dont see where to specify which db to replay in?
"John Bell" wrote:
> hI
> SQL Profiler will capture database activity and you can script the output as
> a SQL file. You can also use the data from profiler to feed into the Index
> tuning wizard, therefore if you have a reasonable profileof the live system
> you can see what it suggests.
> John
> "ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
> news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
>
>
|||Hi
The replay will use the default database of the account you logged in as,
therefore it looks like you are issuing a USE statement and have not
included it in the replay or you are using a different account?
John
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:564DF6FA-D4BE-48B6-83C2-D8831447607C@.microsoft.com...[vbcol=seagreen]
> I'm able to trace to a trace file and replay. But its trying to replay in
> Master. I dont see where to specify which db to replay in?
> "John Bell" wrote:
output as[vbcol=seagreen]
Index[vbcol=seagreen]
system[vbcol=seagreen]
performance[vbcol=seagreen]
|||As well as standard Profiler you might want to have a look at
Support Tools Available For Stress Testing & Performance Analysis
http://www.microsoft.com/downloads/d...DisplayLang=en
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> sql2k
> Is there a tool that I can:
> Box1 and Box2 start with exactly the same data.
> Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> queries/ everything except maybe for jobs.
> Run all of those activities on Box2. The goal being to make performance
> adjustments and see if they do anything.
> TIA, ChrisR
Showing posts with label inserts. Show all posts
Showing posts with label inserts. Show all posts
Wednesday, March 21, 2012
playback tool
sql2k
Is there a tool that I can:
Box1 and Box2 start with exactly the same data.
Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
queries/ everything except maybe for jobs.
Run all of those activities on Box2. The goal being to make performance
adjustments and see if they do anything.
TIA, ChrisRhI
SQL Profiler will capture database activity and you can script the output as
a SQL file. You can also use the data from profiler to feed into the Index
tuning wizard, therefore if you have a reasonable profileof the live system
you can see what it suggests.
John
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> sql2k
> Is there a tool that I can:
> Box1 and Box2 start with exactly the same data.
> Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> queries/ everything except maybe for jobs.
> Run all of those activities on Box2. The goal being to make performance
> adjustments and see if they do anything.
> TIA, ChrisR|||Yes,
Read the help file in the SQL Profiler. There are about 6 items that you
must log in order to do this.
Rick Sawtell
MCT, MCSD, MCDBA
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> sql2k
> Is there a tool that I can:
> Box1 and Box2 start with exactly the same data.
> Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> queries/ everything except maybe for jobs.
> Run all of those activities on Box2. The goal being to make performance
> adjustments and see if they do anything.
> TIA, ChrisR|||The help file is quite lengthy. Could you point me in the right direction?
What do I type in the Index?
"Rick Sawtell" wrote:
> Yes,
> Read the help file in the SQL Profiler. There are about 6 items that you
> must log in order to do this.
> Rick Sawtell
> MCT, MCSD, MCDBA
>
> "ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
> news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
>
>|||I'm able to trace to a trace file and replay. But its trying to replay in
Master. I dont see where to specify which db to replay in?
"John Bell" wrote:
> hI
> SQL Profiler will capture database activity and you can script the output
as
> a SQL file. You can also use the data from profiler to feed into the Index
> tuning wizard, therefore if you have a reasonable profileof the live syste
m
> you can see what it suggests.
> John
> "ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
> news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
>
>|||Hi
The replay will use the default database of the account you logged in as,
therefore it looks like you are issuing a USE statement and have not
included it in the replay or you are using a different account?
John
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:564DF6FA-D4BE-48B6-83C2-D8831447607C@.microsoft.com...[vbcol=seagreen]
> I'm able to trace to a trace file and replay. But its trying to replay in
> Master. I dont see where to specify which db to replay in?
> "John Bell" wrote:
>
output as[vbcol=seagreen]
Index[vbcol=seagreen]
system[vbcol=seagreen]
performance[vbcol=seagreen]|||As well as standard Profiler you might want to have a look at
Support Tools Available For Stress Testing & Performance Analysis
http://www.microsoft.com/downloads/...&DisplayLang=en
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> sql2k
> Is there a tool that I can:
> Box1 and Box2 start with exactly the same data.
> Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> queries/ everything except maybe for jobs.
> Run all of those activities on Box2. The goal being to make performance
> adjustments and see if they do anything.
> TIA, ChrisR
Is there a tool that I can:
Box1 and Box2 start with exactly the same data.
Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
queries/ everything except maybe for jobs.
Run all of those activities on Box2. The goal being to make performance
adjustments and see if they do anything.
TIA, ChrisRhI
SQL Profiler will capture database activity and you can script the output as
a SQL file. You can also use the data from profiler to feed into the Index
tuning wizard, therefore if you have a reasonable profileof the live system
you can see what it suggests.
John
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> sql2k
> Is there a tool that I can:
> Box1 and Box2 start with exactly the same data.
> Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> queries/ everything except maybe for jobs.
> Run all of those activities on Box2. The goal being to make performance
> adjustments and see if they do anything.
> TIA, ChrisR|||Yes,
Read the help file in the SQL Profiler. There are about 6 items that you
must log in order to do this.
Rick Sawtell
MCT, MCSD, MCDBA
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> sql2k
> Is there a tool that I can:
> Box1 and Box2 start with exactly the same data.
> Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> queries/ everything except maybe for jobs.
> Run all of those activities on Box2. The goal being to make performance
> adjustments and see if they do anything.
> TIA, ChrisR|||The help file is quite lengthy. Could you point me in the right direction?
What do I type in the Index?
"Rick Sawtell" wrote:
> Yes,
> Read the help file in the SQL Profiler. There are about 6 items that you
> must log in order to do this.
> Rick Sawtell
> MCT, MCSD, MCDBA
>
> "ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
> news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
>
>|||I'm able to trace to a trace file and replay. But its trying to replay in
Master. I dont see where to specify which db to replay in?
"John Bell" wrote:
> hI
> SQL Profiler will capture database activity and you can script the output
as
> a SQL file. You can also use the data from profiler to feed into the Index
> tuning wizard, therefore if you have a reasonable profileof the live syste
m
> you can see what it suggests.
> John
> "ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
> news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
>
>|||Hi
The replay will use the default database of the account you logged in as,
therefore it looks like you are issuing a USE statement and have not
included it in the replay or you are using a different account?
John
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:564DF6FA-D4BE-48B6-83C2-D8831447607C@.microsoft.com...[vbcol=seagreen]
> I'm able to trace to a trace file and replay. But its trying to replay in
> Master. I dont see where to specify which db to replay in?
> "John Bell" wrote:
>
output as[vbcol=seagreen]
Index[vbcol=seagreen]
system[vbcol=seagreen]
performance[vbcol=seagreen]|||As well as standard Profiler you might want to have a look at
Support Tools Available For Stress Testing & Performance Analysis
http://www.microsoft.com/downloads/...&DisplayLang=en
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> sql2k
> Is there a tool that I can:
> Box1 and Box2 start with exactly the same data.
> Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> queries/ everything except maybe for jobs.
> Run all of those activities on Box2. The goal being to make performance
> adjustments and see if they do anything.
> TIA, ChrisR
playback tool
sql2k
Is there a tool that I can:
Box1 and Box2 start with exactly the same data.
Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
queries/ everything except maybe for jobs.
Run all of those activities on Box2. The goal being to make performance
adjustments and see if they do anything.
TIA, ChrisRhI
SQL Profiler will capture database activity and you can script the output as
a SQL file. You can also use the data from profiler to feed into the Index
tuning wizard, therefore if you have a reasonable profileof the live system
you can see what it suggests.
John
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> sql2k
> Is there a tool that I can:
> Box1 and Box2 start with exactly the same data.
> Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> queries/ everything except maybe for jobs.
> Run all of those activities on Box2. The goal being to make performance
> adjustments and see if they do anything.
> TIA, ChrisR|||Yes,
Read the help file in the SQL Profiler. There are about 6 items that you
must log in order to do this.
Rick Sawtell
MCT, MCSD, MCDBA
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> sql2k
> Is there a tool that I can:
> Box1 and Box2 start with exactly the same data.
> Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> queries/ everything except maybe for jobs.
> Run all of those activities on Box2. The goal being to make performance
> adjustments and see if they do anything.
> TIA, ChrisR|||The help file is quite lengthy. Could you point me in the right direction?
What do I type in the Index?
"Rick Sawtell" wrote:
> Yes,
> Read the help file in the SQL Profiler. There are about 6 items that you
> must log in order to do this.
> Rick Sawtell
> MCT, MCSD, MCDBA
>
> "ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
> news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> > sql2k
> >
> > Is there a tool that I can:
> >
> > Box1 and Box2 start with exactly the same data.
> >
> > Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> > queries/ everything except maybe for jobs.
> >
> > Run all of those activities on Box2. The goal being to make performance
> > adjustments and see if they do anything.
> >
> > TIA, ChrisR
>
>|||I'm able to trace to a trace file and replay. But its trying to replay in
Master. I dont see where to specify which db to replay in?
"John Bell" wrote:
> hI
> SQL Profiler will capture database activity and you can script the output as
> a SQL file. You can also use the data from profiler to feed into the Index
> tuning wizard, therefore if you have a reasonable profileof the live system
> you can see what it suggests.
> John
> "ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
> news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> > sql2k
> >
> > Is there a tool that I can:
> >
> > Box1 and Box2 start with exactly the same data.
> >
> > Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> > queries/ everything except maybe for jobs.
> >
> > Run all of those activities on Box2. The goal being to make performance
> > adjustments and see if they do anything.
> >
> > TIA, ChrisR
>
>|||Hi
The replay will use the default database of the account you logged in as,
therefore it looks like you are issuing a USE statement and have not
included it in the replay or you are using a different account?
John
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:564DF6FA-D4BE-48B6-83C2-D8831447607C@.microsoft.com...
> I'm able to trace to a trace file and replay. But its trying to replay in
> Master. I dont see where to specify which db to replay in?
> "John Bell" wrote:
> > hI
> >
> > SQL Profiler will capture database activity and you can script the
output as
> > a SQL file. You can also use the data from profiler to feed into the
Index
> > tuning wizard, therefore if you have a reasonable profileof the live
system
> > you can see what it suggests.
> >
> > John
> >
> > "ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
> > news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> > > sql2k
> > >
> > > Is there a tool that I can:
> > >
> > > Box1 and Box2 start with exactly the same data.
> > >
> > > Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> > > queries/ everything except maybe for jobs.
> > >
> > > Run all of those activities on Box2. The goal being to make
performance
> > > adjustments and see if they do anything.
> > >
> > > TIA, ChrisR
> >
> >
> >|||As well as standard Profiler you might want to have a look at
Support Tools Available For Stress Testing & Performance Analysis
http://www.microsoft.com/downloads/details.aspx?FamilyID=5691ab53-893a-4aaf-b4a6-9a8bb9669a8b&DisplayLang=en
--
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> sql2k
> Is there a tool that I can:
> Box1 and Box2 start with exactly the same data.
> Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> queries/ everything except maybe for jobs.
> Run all of those activities on Box2. The goal being to make performance
> adjustments and see if they do anything.
> TIA, ChrisR
Is there a tool that I can:
Box1 and Box2 start with exactly the same data.
Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
queries/ everything except maybe for jobs.
Run all of those activities on Box2. The goal being to make performance
adjustments and see if they do anything.
TIA, ChrisRhI
SQL Profiler will capture database activity and you can script the output as
a SQL file. You can also use the data from profiler to feed into the Index
tuning wizard, therefore if you have a reasonable profileof the live system
you can see what it suggests.
John
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> sql2k
> Is there a tool that I can:
> Box1 and Box2 start with exactly the same data.
> Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> queries/ everything except maybe for jobs.
> Run all of those activities on Box2. The goal being to make performance
> adjustments and see if they do anything.
> TIA, ChrisR|||Yes,
Read the help file in the SQL Profiler. There are about 6 items that you
must log in order to do this.
Rick Sawtell
MCT, MCSD, MCDBA
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> sql2k
> Is there a tool that I can:
> Box1 and Box2 start with exactly the same data.
> Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> queries/ everything except maybe for jobs.
> Run all of those activities on Box2. The goal being to make performance
> adjustments and see if they do anything.
> TIA, ChrisR|||The help file is quite lengthy. Could you point me in the right direction?
What do I type in the Index?
"Rick Sawtell" wrote:
> Yes,
> Read the help file in the SQL Profiler. There are about 6 items that you
> must log in order to do this.
> Rick Sawtell
> MCT, MCSD, MCDBA
>
> "ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
> news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> > sql2k
> >
> > Is there a tool that I can:
> >
> > Box1 and Box2 start with exactly the same data.
> >
> > Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> > queries/ everything except maybe for jobs.
> >
> > Run all of those activities on Box2. The goal being to make performance
> > adjustments and see if they do anything.
> >
> > TIA, ChrisR
>
>|||I'm able to trace to a trace file and replay. But its trying to replay in
Master. I dont see where to specify which db to replay in?
"John Bell" wrote:
> hI
> SQL Profiler will capture database activity and you can script the output as
> a SQL file. You can also use the data from profiler to feed into the Index
> tuning wizard, therefore if you have a reasonable profileof the live system
> you can see what it suggests.
> John
> "ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
> news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> > sql2k
> >
> > Is there a tool that I can:
> >
> > Box1 and Box2 start with exactly the same data.
> >
> > Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> > queries/ everything except maybe for jobs.
> >
> > Run all of those activities on Box2. The goal being to make performance
> > adjustments and see if they do anything.
> >
> > TIA, ChrisR
>
>|||Hi
The replay will use the default database of the account you logged in as,
therefore it looks like you are issuing a USE statement and have not
included it in the replay or you are using a different account?
John
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:564DF6FA-D4BE-48B6-83C2-D8831447607C@.microsoft.com...
> I'm able to trace to a trace file and replay. But its trying to replay in
> Master. I dont see where to specify which db to replay in?
> "John Bell" wrote:
> > hI
> >
> > SQL Profiler will capture database activity and you can script the
output as
> > a SQL file. You can also use the data from profiler to feed into the
Index
> > tuning wizard, therefore if you have a reasonable profileof the live
system
> > you can see what it suggests.
> >
> > John
> >
> > "ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
> > news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> > > sql2k
> > >
> > > Is there a tool that I can:
> > >
> > > Box1 and Box2 start with exactly the same data.
> > >
> > > Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> > > queries/ everything except maybe for jobs.
> > >
> > > Run all of those activities on Box2. The goal being to make
performance
> > > adjustments and see if they do anything.
> > >
> > > TIA, ChrisR
> >
> >
> >|||As well as standard Profiler you might want to have a look at
Support Tools Available For Stress Testing & Performance Analysis
http://www.microsoft.com/downloads/details.aspx?FamilyID=5691ab53-893a-4aaf-b4a6-9a8bb9669a8b&DisplayLang=en
--
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:B9839F43-5BC8-44DC-922D-D4A20EFD175C@.microsoft.com...
> sql2k
> Is there a tool that I can:
> Box1 and Box2 start with exactly the same data.
> Collect all activity for a day on Box1. Inserts/ Updates/ Deletes/ all
> queries/ everything except maybe for jobs.
> Run all of those activities on Box2. The goal being to make performance
> adjustments and see if they do anything.
> TIA, ChrisR
Monday, March 12, 2012
Place count in variable
Would like to know if this is even possible to do - using SQL Server 2000.
I am creating a procedure that truncates a table then inserts one row of dat
a.
In the third field I need to insert the count of another table.
I thought that this would work:
@.DetCount int = SELECT Count(*) FROM TableName
My question is can I assign a count(*) to a variable in a stored procedure?
I would then use the variable in the values clause of the insert statment.Hi Robert,
Yes - you can do that. You just need to wrap your Select Statement in
brackets.
e.g
Declare @.Count Int
Set @.Count = (Select count(*) From TableA)
Insert Into TableB (Col1)
Values (@.Count)
Select * From TableB
HTH
Barry|||Works perfect! Thanks a million.
"Barry" wrote:
> Hi Robert,
> Yes - you can do that. You just need to wrap your Select Statement in
> brackets.
> e.g
> Declare @.Count Int
> Set @.Count = (Select count(*) From TableA)
> Insert Into TableB (Col1)
> Values (@.Count)
>
> Select * From TableB
>
> HTH
> Barry
>|||The other option is to use the SELECT statement to assign values to a
variable:
SELECT @.Count = COUNT(*) FROM TableA
This is useful when setting the values of multiple variables at once,
e.g.:
SELECT @.Count = COUNT(*),
@.Avg = AVG(someColumn)
FROM TableA
HTH,
Stu
I am creating a procedure that truncates a table then inserts one row of dat
a.
In the third field I need to insert the count of another table.
I thought that this would work:
@.DetCount int = SELECT Count(*) FROM TableName
My question is can I assign a count(*) to a variable in a stored procedure?
I would then use the variable in the values clause of the insert statment.Hi Robert,
Yes - you can do that. You just need to wrap your Select Statement in
brackets.
e.g
Declare @.Count Int
Set @.Count = (Select count(*) From TableA)
Insert Into TableB (Col1)
Values (@.Count)
Select * From TableB
HTH
Barry|||Works perfect! Thanks a million.
"Barry" wrote:
> Hi Robert,
> Yes - you can do that. You just need to wrap your Select Statement in
> brackets.
> e.g
> Declare @.Count Int
> Set @.Count = (Select count(*) From TableA)
> Insert Into TableB (Col1)
> Values (@.Count)
>
> Select * From TableB
>
> HTH
> Barry
>|||The other option is to use the SELECT statement to assign values to a
variable:
SELECT @.Count = COUNT(*) FROM TableA
This is useful when setting the values of multiple variables at once,
e.g.:
SELECT @.Count = COUNT(*),
@.Avg = AVG(someColumn)
FROM TableA
HTH,
Stu
Subscribe to:
Posts (Atom)