Showing posts with label return. Show all posts
Showing posts with label return. Show all posts

Tuesday, March 27, 2012

@@Identity does not return the correct value.

@.@.Identity does not return the correct value.
Anyone have any ideas how to fix this,
and more important,
how does it get out of sync and return the wrong value?
Account.AccountID = (int IDENTITY, PRIMARY KEY )
/* Three statements executed together */
EXEC ('DBCC CheckIdent(Account)')
INSERT Account(AccountNumber, AccountAccountStatus,
AccountAgency, AccountAgencyClientID,
AccountPaymentAmount)
VALUES('9',2,1,'sadasd',787.8)
SELECT @.@.IDENTITY as "AccountID = @.@.IDENTITY", Max
(AccountID) as "Max(AccountID)" from Account
/* Results of three statements executed together */
Checking identity information: current identity
value '261', current column value '261'.
DBCC execution completed. If DBCC printed error messages,
contact your system administrator.
(1 row(s) affected)
AccountID = @.@.IDENTITY Max(AccountID)
-- --
543 262
(1 row(s) affected)Do you have a trigger on the table? What does SCOPE_IDENTITY() give you?
--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Ken" <KLomax@.Noteworld.com> wrote in message
news:059501c3aac8$d8d00b40$a001280a@.phx.gbl...
> @.@.Identity does not return the correct value.
> Anyone have any ideas how to fix this,
> and more important,
> how does it get out of sync and return the wrong value?
> Account.AccountID = (int IDENTITY, PRIMARY KEY )
> /* Three statements executed together */
> EXEC ('DBCC CheckIdent(Account)')
> INSERT Account(AccountNumber, AccountAccountStatus,
> AccountAgency, AccountAgencyClientID,
> AccountPaymentAmount)
> VALUES('9',2,1,'sadasd',787.8)
> SELECT @.@.IDENTITY as "AccountID = @.@.IDENTITY", Max
> (AccountID) as "Max(AccountID)" from Account
> /* Results of three statements executed together */
> Checking identity information: current identity
> value '261', current column value '261'.
> DBCC execution completed. If DBCC printed error messages,
> contact your system administrator.
> (1 row(s) affected)
> AccountID = @.@.IDENTITY Max(AccountID)
> -- --
> 543 262
> (1 row(s) affected)
>|||Do you have a trigger on the table, perhaps doing an insert to another
table?
If so, that's why you'll see that problem... Use SCOPE_IDENTITY() instead...
"Ken" <KLomax@.Noteworld.com> wrote in message
news:059501c3aac8$d8d00b40$a001280a@.phx.gbl...
> @.@.Identity does not return the correct value.
> Anyone have any ideas how to fix this,
> and more important,
> how does it get out of sync and return the wrong value?
> Account.AccountID = (int IDENTITY, PRIMARY KEY )
> /* Three statements executed together */
> EXEC ('DBCC CheckIdent(Account)')
> INSERT Account(AccountNumber, AccountAccountStatus,
> AccountAgency, AccountAgencyClientID,
> AccountPaymentAmount)
> VALUES('9',2,1,'sadasd',787.8)
> SELECT @.@.IDENTITY as "AccountID = @.@.IDENTITY", Max
> (AccountID) as "Max(AccountID)" from Account
> /* Results of three statements executed together */
> Checking identity information: current identity
> value '261', current column value '261'.
> DBCC execution completed. If DBCC printed error messages,
> contact your system administrator.
> (1 row(s) affected)
> AccountID = @.@.IDENTITY Max(AccountID)
> -- --
> 543 262
> (1 row(s) affected)
>|||Tibor:
You are the man!
I did not realize @.@.Identity was not scope specific.
SCOPE_IDENTITY() fixes the problem.
I have a trigger that inserts audit records on updates and
inserts, so @.@.Identity was returning the key of the audit
table, not the Account table.
THANK YOU.
Ken
>--Original Message--
>Do you have a trigger on the table? What does
SCOPE_IDENTITY() give you?
>--
>Tibor Karaszi, SQL Server MVP
>Archive at:
>http://groups.google.com/groups?
oi=djq&as_ugroup=microsoft.public.sqlserver
>
>"Ken" <KLomax@.Noteworld.com> wrote in message
>news:059501c3aac8$d8d00b40$a001280a@.phx.gbl...
>> @.@.Identity does not return the correct value.
>> Anyone have any ideas how to fix this,
>> and more important,
>> how does it get out of sync and return the wrong value?
>> Account.AccountID = (int IDENTITY, PRIMARY KEY )
>> /* Three statements executed together */
>> EXEC ('DBCC CheckIdent(Account)')
>> INSERT Account(AccountNumber, AccountAccountStatus,
>> AccountAgency, AccountAgencyClientID,
>> AccountPaymentAmount)
>> VALUES('9',2,1,'sadasd',787.8)
>> SELECT @.@.IDENTITY as "AccountID = @.@.IDENTITY", Max
>> (AccountID) as "Max(AccountID)" from Account
>> /* Results of three statements executed together */
>> Checking identity information: current identity
>> value '261', current column value '261'.
>> DBCC execution completed. If DBCC printed error
messages,
>> contact your system administrator.
>> (1 row(s) affected)
>> AccountID = @.@.IDENTITY Max(AccountID)
>> -- --
>> 543 262
>> (1 row(s) affected)
>
>.
>|||Adam:
You are the man!
I did not realize @.@.Identity was not scope specific.
SCOPE_IDENTITY() fixes the problem.
I have a trigger that inserts audit records on updates and
inserts, so @.@.Identity was returning the key of the audit
table, not the Account table.
THANK YOU.
Ken
>--Original Message--
>Do you have a trigger on the table, perhaps doing an
insert to another
>table?
>If so, that's why you'll see that problem... Use
SCOPE_IDENTITY() instead...
>
>"Ken" <KLomax@.Noteworld.com> wrote in message
>news:059501c3aac8$d8d00b40$a001280a@.phx.gbl...
>> @.@.Identity does not return the correct value.
>> Anyone have any ideas how to fix this,
>> and more important,
>> how does it get out of sync and return the wrong value?
>> Account.AccountID = (int IDENTITY, PRIMARY KEY )
>> /* Three statements executed together */
>> EXEC ('DBCC CheckIdent(Account)')
>> INSERT Account(AccountNumber, AccountAccountStatus,
>> AccountAgency, AccountAgencyClientID,
>> AccountPaymentAmount)
>> VALUES('9',2,1,'sadasd',787.8)
>> SELECT @.@.IDENTITY as "AccountID = @.@.IDENTITY", Max
>> (AccountID) as "Max(AccountID)" from Account
>> /* Results of three statements executed together */
>> Checking identity information: current identity
>> value '261', current column value '261'.
>> DBCC execution completed. If DBCC printed error
messages,
>> contact your system administrator.
>> (1 row(s) affected)
>> AccountID = @.@.IDENTITY Max(AccountID)
>> -- --
>> 543 262
>> (1 row(s) affected)
>
>.
>|||Wait, I thought Tibor was the man. Who exactly _is_ the man? : )
<anonymous@.discussions.microsoft.com> wrote in message
news:001b01c3aadb$85d144f0$a501280a@.phx.gbl...
> Adam:
> You are the man!
> I did not realize @.@.Identity was not scope specific.
> SCOPE_IDENTITY() fixes the problem.
> I have a trigger that inserts audit records on updates and
> inserts, so @.@.Identity was returning the key of the audit
> table, not the Account table.
> THANK YOU.
> Ken
> >--Original Message--
> >Do you have a trigger on the table, perhaps doing an
> insert to another
> >table?
> >
> >If so, that's why you'll see that problem... Use
> SCOPE_IDENTITY() instead...
> >
> >
> >"Ken" <KLomax@.Noteworld.com> wrote in message
> >news:059501c3aac8$d8d00b40$a001280a@.phx.gbl...
> >> @.@.Identity does not return the correct value.
> >>
> >> Anyone have any ideas how to fix this,
> >> and more important,
> >> how does it get out of sync and return the wrong value?
> >>
> >> Account.AccountID = (int IDENTITY, PRIMARY KEY )
> >>
> >> /* Three statements executed together */
> >> EXEC ('DBCC CheckIdent(Account)')
> >>
> >> INSERT Account(AccountNumber, AccountAccountStatus,
> >> AccountAgency, AccountAgencyClientID,
> >> AccountPaymentAmount)
> >> VALUES('9',2,1,'sadasd',787.8)
> >>
> >> SELECT @.@.IDENTITY as "AccountID = @.@.IDENTITY", Max
> >> (AccountID) as "Max(AccountID)" from Account
> >>
> >> /* Results of three statements executed together */
> >> Checking identity information: current identity
> >> value '261', current column value '261'.
> >> DBCC execution completed. If DBCC printed error
> messages,
> >> contact your system administrator.
> >>
> >> (1 row(s) affected)
> >>
> >> AccountID = @.@.IDENTITY Max(AccountID)
> >> -- --
> >> 543 262
> >>
> >> (1 row(s) affected)
> >>
> >
> >
> >.
> >|||I think we're gonna have to take this outside.
"Eric Sabine" <mopar41@.hyottmail.com> wrote in message
news:3fb54413$0$43854$39cecf19@.news.twtelecom.net...
> Wait, I thought Tibor was the man. Who exactly _is_ the man? : )
>

@@Error not catching error.

Hi all,

I want to catch error in stored procedure and return error message.
I want to catch error 'Syntax error converting the varchar value 'a'
to a column of data type int.' Means error occuring if i enter wrong
value.

Say suppose i have statment like

select * from emp where rowid = 'a'
PRINT @.@.ERROR
print 'reach'

here rowid is integer value so i am getting above mention error.

So what i am expecting is it should print error and then print 'reach'
which is not happening.
can anyone tell me reason behind this and how to overcome this
problem.

thanks in advance.(trialproduct2004@.yahoo.com) writes:

Quote:

Originally Posted by

I want to catch error in stored procedure and return error message.
I want to catch error 'Syntax error converting the varchar value 'a'
to a column of data type int.' Means error occuring if i enter wrong
value.
>
Say suppose i have statment like
>
select * from emp where rowid = 'a'
PRINT @.@.ERROR
print 'reach'
>
here rowid is integer value so i am getting above mention error.
>
So what i am expecting is it should print error and then print 'reach'
which is not happening.
can anyone tell me reason behind this and how to overcome this
problem.


If you are on SQL 2005, you need to use TRY-CATCH. If you are using SQL
2000, you first need to upgrade to SQL 2005. In SQL 2000 you cannot detect
this error, because the entire batch is aborted because of the error.
If you want to know more about error handling in SQL 2000, I have an
article on my web site: http://www.sommarskog.se/error-handling-I.html.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||(trialproduct2004@.yahoo.com) writes:

Quote:

Originally Posted by

I want to catch error in stored procedure and return error message.
I want to catch error 'Syntax error converting the varchar value 'a'
to a column of data type int.' Means error occuring if i enter wrong
value.
>
Say suppose i have statment like
>
select * from emp where rowid = 'a'
PRINT @.@.ERROR
print 'reach'
>
here rowid is integer value so i am getting above mention error.
>
So what i am expecting is it should print error and then print 'reach'
which is not happening.
can anyone tell me reason behind this and how to overcome this
problem.


If you are on SQL 2005, you need to use TRY-CATCH. If you are using SQL
2000, you first need to upgrade to SQL 2005. In SQL 2000 you cannot detect
this error, because the entire batch is aborted because of the error.
If you want to know more about error handling in SQL 2000, I have an
article on my web site: http://www.sommarskog.se/error-handling-I.html.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Tuesday, March 20, 2012

::fn_virtualfilestats does not return any rows

Is there any pre-requirements in order to use ::fn_virtualfilestats function.
When i ran "select * from ::fn_virtualfilestats" in SQLServer2000 returns
always 0 rows.
Need help !!!
thanks
Hi
You have to supply the DatabaseID and FileID.
e.g.
SELECT *
FROM :: fn_virtualfilestats(1, 1)
See BOL for full information.
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"jesenko k via droptable.com" <forum@.droptable.com> wrote in message
news:512B9BEB34B40@.droptable.com...
> Is there any pre-requirements in order to use ::fn_virtualfilestats
> function.
> When i ran "select * from ::fn_virtualfilestats" in SQLServer2000 returns
> always 0 rows.
> Need help !!!
> thanks
|||Or to get all the files for all the db's you can do this:
SELECT *
FROM :: fn_virtualfilestats(-1, -1)
Andrew J. Kelly SQL MVP
"Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
news:eMd3kjkhFHA.1480@.TK2MSFTNGP10.phx.gbl...
> Hi
> You have to supply the DatabaseID and FileID.
> e.g.
> SELECT *
> FROM :: fn_virtualfilestats(1, 1)
> See BOL for full information.
> --
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "jesenko k via droptable.com" <forum@.droptable.com> wrote in message
> news:512B9BEB34B40@.droptable.com...
>
|||SELECT * FROM :: fn_virtualfilestats(-1, -1)
STILL NO ROWS
Message posted via droptable.com
http://www.droptable.com/Uwe/Forums...erver/200507/1
|||Do you have SQL perfmon counters? What do you get in the last waittype
column if you select * from sysprocesses? If it always shows misc then you
blew away your counters. This can usually be fixed by restarting sql server
and ensuring NOTHING is monitoring any sql perfmon counters at the time.
This may be helpful as well:
http://www.extremeexperts.com/SQL/FA...rCounters.aspx
Andrew J. Kelly SQL MVP
"jesenko k via droptable.com" <forum@.droptable.com> wrote in message
news:512CA670C3120@.droptable.com...
> SELECT * FROM :: fn_virtualfilestats(-1, -1)
> STILL NO ROWS
>
> --
> Message posted via droptable.com
> http://www.droptable.com/Uwe/Forums...erver/200507/1
|||Probably your perf mon counters are not working.
Does select * from master.dbo.sysperfinfo return any data?
If not either your server is started with the -x option or you perfmon
counter are no longer working.
GertD@.SQLDev.Net
Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
Copyright SQLDev.Net 1991-2005 All rights reserved.
"jesenko k via droptable.com" <forum@.droptable.com> wrote in message
news:512CA670C3120@.droptable.com...
> SELECT * FROM :: fn_virtualfilestats(-1, -1)
> STILL NO ROWS
>
> --
> Message posted via droptable.com
> http://www.droptable.com/Uwe/Forums...erver/200507/1
|||Do you have SQL perfmon counters?
I AM ORACLE GUY. I DO NOT KNOW.
What do you get in the lastwaittype column if you select * from sysprocesses?
ONLY "MISCELLANEOUS"
This can usually be fixed by restarting sql server and ensuring NOTHING is
monitoring any sql perfmon counters at the time.
ALREADY TRIED. DOES NOT WORK
http://www.extremeexperts.com/SQL/FA...rCounters.aspx
I'LL TRY THIS. LET YOU KNOW
Does select * from master.dbo.sysperfinfo return any data?
NO DATA
If not either your server is started with the -x option or you perfmon
counter are no longer working.
IT SEEMS TO ME PERFMON COUNTER DOES NOT WORK
Thanks
Message posted via droptable.com
http://www.droptable.com/Uwe/Forums...erver/200507/1
|||i made it work reloading counters
1) unlodctr MSSQLServer
2) lodctr sqlctr.ini
3) net stop mssqlserver
4) net start mssqlserver
now it works
thanks
Message posted via http://www.droptable.com

::fn_virtualfilestats does not return any rows

Is there any pre-requirements in order to use ::fn_virtualfilestats function
.
When i ran "select * from ::fn_virtualfilestats" in SQLServer2000 returns
always 0 rows.
Need help !!!
thanksHi
You have to supply the DatabaseID and FileID.
e.g.
SELECT *
FROM :: fn_virtualfilestats(1, 1)
See BOL for full information.
--
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"jesenko k via droptable.com" <forum@.droptable.com> wrote in message
news:512B9BEB34B40@.droptable.com...
> Is there any pre-requirements in order to use ::fn_virtualfilestats
> function.
> When i ran "select * from ::fn_virtualfilestats" in SQLServer2000 returns
> always 0 rows.
> Need help !!!
> thanks|||Or to get all the files for all the db's you can do this:
SELECT *
FROM :: fn_virtualfilestats(-1, -1)
Andrew J. Kelly SQL MVP
"Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
news:eMd3kjkhFHA.1480@.TK2MSFTNGP10.phx.gbl...
> Hi
> You have to supply the DatabaseID and FileID.
> e.g.
> SELECT *
> FROM :: fn_virtualfilestats(1, 1)
> See BOL for full information.
> --
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "jesenko k via droptable.com" <forum@.droptable.com> wrote in message
> news:512B9BEB34B40@.droptable.com...
>|||SELECT * FROM :: fn_virtualfilestats(-1, -1)
STILL NO ROWS
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200507/1|||Do you have SQL perfmon counters? What do you get in the last waittype
column if you select * from sysprocesses? If it always shows misc then you
blew away your counters. This can usually be fixed by restarting sql server
and ensuring NOTHING is monitoring any sql perfmon counters at the time.
This may be helpful as well:
http://www.extremeexperts.com/SQL/F...erCounters.aspx
Andrew J. Kelly SQL MVP
"jesenko k via droptable.com" <forum@.droptable.com> wrote in message
news:512CA670C3120@.droptable.com...
> SELECT * FROM :: fn_virtualfilestats(-1, -1)
> STILL NO ROWS
>
> --
> Message posted via droptable.com
> http://www.droptable.com/Uwe/Forum...server/200507/1|||Probably your perf mon counters are not working.
Does select * from master.dbo.sysperfinfo return any data?
If not either your server is started with the -x option or you perfmon
counter are no longer working.
GertD@.SQLDev.Net
Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
Copyright SQLDev.Net 1991-2005 All rights reserved.
"jesenko k via droptable.com" <forum@.droptable.com> wrote in message
news:512CA670C3120@.droptable.com...
> SELECT * FROM :: fn_virtualfilestats(-1, -1)
> STILL NO ROWS
>
> --
> Message posted via droptable.com
> http://www.droptable.com/Uwe/Forum...server/200507/1|||Do you have SQL perfmon counters?
I AM ORACLE GUY. I DO NOT KNOW.
What do you get in the lastwaittype column if you select * from sysprocesses
?
ONLY "MISCELLANEOUS"
This can usually be fixed by restarting sql server and ensuring NOTHING is
monitoring any sql perfmon counters at the time.
ALREADY TRIED. DOES NOT WORK
http://www.extremeexperts.com/SQL/F...erCounters.aspx
I'LL TRY THIS. LET YOU KNOW
Does select * from master.dbo.sysperfinfo return any data?
NO DATA
If not either your server is started with the -x option or you perfmon
counter are no longer working.
IT SEEMS TO ME PERFMON COUNTER DOES NOT WORK
Thanks
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200507/1|||i made it work reloading counters
1) unlodctr MSSQLServer
2) lodctr sqlctr.ini
3) net stop mssqlserver
4) net start mssqlserver
now it works
thanks
Message posted via http://www.droptable.comsql

::fn_virtualfilestats does not return any rows

Is there any pre-requirements in order to use ::fn_virtualfilestats function.
When i ran "select * from ::fn_virtualfilestats" in SQLServer2000 returns
always 0 rows.
Need help !!!
thanksHi
You have to supply the DatabaseID and FileID.
e.g.
SELECT *
FROM :: fn_virtualfilestats(1, 1)
See BOL for full information.
--
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"jesenko k via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
news:512B9BEB34B40@.SQLMonster.com...
> Is there any pre-requirements in order to use ::fn_virtualfilestats
> function.
> When i ran "select * from ::fn_virtualfilestats" in SQLServer2000 returns
> always 0 rows.
> Need help !!!
> thanks|||Or to get all the files for all the db's you can do this:
SELECT *
FROM :: fn_virtualfilestats(-1, -1)
--
Andrew J. Kelly SQL MVP
"Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
news:eMd3kjkhFHA.1480@.TK2MSFTNGP10.phx.gbl...
> Hi
> You have to supply the DatabaseID and FileID.
> e.g.
> SELECT *
> FROM :: fn_virtualfilestats(1, 1)
> See BOL for full information.
> --
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "jesenko k via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
> news:512B9BEB34B40@.SQLMonster.com...
>> Is there any pre-requirements in order to use ::fn_virtualfilestats
>> function.
>> When i ran "select * from ::fn_virtualfilestats" in SQLServer2000 returns
>> always 0 rows.
>> Need help !!!
>> thanks
>|||SELECT * FROM :: fn_virtualfilestats(-1, -1)
STILL NO ROWS
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200507/1|||Do you have SQL perfmon counters? What do you get in the last waittype
column if you select * from sysprocesses? If it always shows misc then you
blew away your counters. This can usually be fixed by restarting sql server
and ensuring NOTHING is monitoring any sql perfmon counters at the time.
This may be helpful as well:
http://www.extremeexperts.com/SQL/FAQ/EnablingPerCounters.aspx
Andrew J. Kelly SQL MVP
"jesenko k via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
news:512CA670C3120@.SQLMonster.com...
> SELECT * FROM :: fn_virtualfilestats(-1, -1)
> STILL NO ROWS
>
> --
> Message posted via SQLMonster.com
> http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200507/1|||Probably your perf mon counters are not working.
Does select * from master.dbo.sysperfinfo return any data?
If not either your server is started with the -x option or you perfmon
counter are no longer working.
GertD@.SQLDev.Net
Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
Copyright © SQLDev.Net 1991-2005 All rights reserved.
"jesenko k via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
news:512CA670C3120@.SQLMonster.com...
> SELECT * FROM :: fn_virtualfilestats(-1, -1)
> STILL NO ROWS
>
> --
> Message posted via SQLMonster.com
> http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200507/1|||Do you have SQL perfmon counters?
I AM ORACLE GUY. I DO NOT KNOW.
What do you get in the lastwaittype column if you select * from sysprocesses?
ONLY "MISCELLANEOUS"
This can usually be fixed by restarting sql server and ensuring NOTHING is
monitoring any sql perfmon counters at the time.
ALREADY TRIED. DOES NOT WORK
http://www.extremeexperts.com/SQL/FAQ/EnablingPerCounters.aspx
I'LL TRY THIS. LET YOU KNOW
Does select * from master.dbo.sysperfinfo return any data?
NO DATA
If not either your server is started with the -x option or you perfmon
counter are no longer working.
IT SEEMS TO ME PERFMON COUNTER DOES NOT WORK
Thanks
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200507/1|||i made it work reloading counters
1) unlodctr MSSQLServer
2) lodctr sqlctr.ini
3) net stop mssqlserver
4) net start mssqlserver
now it works
thanks
Message posted via http://www.sqlmonster.com

Saturday, February 11, 2012

(system) Variable that holds the record count of a result set?

Hello
is there a variable that is available to me that contains the number
of rows contained in a dataset return from a database call?

have a class that runs a stored proc and returns a dataset/resultset
looking to simply assign an integer this value if it is possible

i'm using (learning) vb.net and sql server

thanks in advance

If you are using a dataset, you can get the number of rows with this syntax:

DataSet1.tables(0).rows.count (assuming your Dataset returns only 1 resultset. If you have more than 1, just replace the zero with whatever index you need.)

If you use a DataReader, which tends to be faster, this property is not available, unfortunately.|||

hello. thank you for the reply. that is exactly what i was looking for (DataSet1.tables(0).rows.count). a question about how to reference this from the codebehind...

i have a codebehind that Dims a class, the class returns the dataset, in the codebehind i have a line likeDropDownList1.DataSource = myClass.function1(parm1) to populate the dropdown with the data from the dataset. i get how i could reference this value in the class code, but how would i reference it in the codebehind? is there a way. would i have to do it in the class function and store it in a session variable or something? would be like to reference it directly in the codebehind as that is where i would be using the value.

thanks again.

|||

i believe i have figured my question out (yup, i'm new), but if you have any comments i'd appreciate it

instead of directly coding the line as DDL1.DataSource = myClass.function1(parm1)

i modified the code to have...

Dim ds as dataSet = myClass.function1(parm1)
Dim dsCnt as integer = ds.Tables(0).Rows.Count()
DDL1.DataSource = ds

this seemed to get me what i was after. if there is a more efficient or elegant way to do this, i'm all earsSmile [:)]

|||The way you've done it is fine. An alternative is to create a property of type dataset in your class, then fill that property in your function. The code behind could then reference your property.

Public Class myClass

Private mMyDataset as dataset

Public Sub New()
MyBase.new()
End Sub

Property MyDataset() As dataset
Get
Return mMyDataset
End Get
Set(ByVal Value As dataset)
mMyDataset = Value
End Set
End Property

Public Sub function1(param) 'can change to a sub since you are filling a property rather than using a return value
myDataset = Database call goes here
End Sub

From your code behind:

dim objClass as new myClass()

with objClass
.function1(param)
DDL1.datasource = .myDataset
DDL1.databind
end with