Showing posts with label properties. Show all posts
Showing posts with label properties. Show all posts

Wednesday, March 28, 2012

Mapping of columns in SqlDataReader

Hi,

I use SqlDataReader to read one row from database and than set some properties to values retrieved like this:

string myString = myReader.GetValue(0) // this sets myString to first value in a row

If, however, I change order of columns returned by stored procedure myString would be set to wrong value.

Is there a way to do something like this: string myString = myReader.GetValue["ColumnName"];

you can get the ordinal position of your column like this

//dynamicall get our columns position in our readerint myOrdinal = myReader.GetOrdinal["ColumnName"];//use the discovered ordinal to retrieve the datastring myString = myReader.GetValue(myOrdinal);
|||

This looks ok.

One more question. Does this impact performance and how (much)?

|||

it will use a few cpu cycles - but everything does...
If you are iterating over a reader, you can collect all the ordinal positions up front before entering your loop and then you've minimized the overhead.

i can give you an exact performance impact, but i think it's relatively insignificant and i always do it like this so i'm not dependent on the position of the columns in the data being returned.

|||OK, thanks.|||

it should be also possible to do this:

string myString = myReader.GetValue("Column name")

so you can save some processor cycles and memory

Thanks

|||

jpazgier:

it should be also possible to do this:

string myString = myReader.GetValue("Column name")

so you can save some processor cycles and memory

When you access a reader column using the column name, the ordinal lookup is still performed (behind the scenes) so you wont actually get any cpu savings.

when you are iterating over a datareader and you access all your columns by name, you are actually performing this ordinal lookup on each row of data which results in a performance penalty. since the columns cannot move around after you have created your reader, you can collect up all the ordinal positions outside of your loop (before the: while reader.read). then you would use only the pre-collected ordinal positions when inside of your loop.

this should result in a net performance gain.

in my testing, i actually saw about a 10% performance increase when using ordinal column positions over using column names inside the loop.

|||Thank you both. You really pointed out some interesting things. Really helpful.

Mapped Drive

Can I make my "default location" for new databases be a mapped drive? When
I go into the properties and select the database tab and select the ...
box to list my drives, the shared drive does not show up. If I go ahead
and enter the path of where I want the files to be located on the "mapped"
drive, it accepts it, but does not use it when I create a new database.
My situation is I have 2 computers in a single room and I want then to be
pointed at the same file location for all databases... Both machines have
MSDE version of sql server loaded...Can I somehow point one machine to the
second machines SQL server such that we are working on the same database?
Any ideas/suggestions'> MSDE version of sql server loaded...Can I somehow point one machine to
the
> second machines SQL server such that we are working on the same database?
I don't think you can share databases between engines (even between
instances on the same machine).
Why not just point one machine's client tools to the other machine's SQL
Server? Then one machine will be working locally, and the other will be
working "remotely" so to speak. But they will be working on the same copy
of exactly one database.
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/|||No.
First, SQL does not support mapped drives for database or transaction log
files.
Second, when SQL does open a database file, it is completely exclusive for
that server instance. Even a second instance on the same host nod could not
access the same underlying database files.
Geoff N. Hiten
Microsoft SQL Server MVP
Senior Database Administrator
Careerbuilder.com
I support the Professional Association for SQL Server
www.sqlpass.org
"Jim Heavey" <JHeavey@.nospam.com> wrote in message
news:Xns9495971974DBBJHeaveyBDUP@.207.46.248.16...
> Can I make my "default location" for new databases be a mapped drive?
When
> I go into the properties and select the database tab and select the ...
> box to list my drives, the shared drive does not show up. If I go ahead
> and enter the path of where I want the files to be located on the "mapped"
> drive, it accepts it, but does not use it when I create a new database.
> My situation is I have 2 computers in a single room and I want then to be
> pointed at the same file location for all databases... Both machines
have
> MSDE version of sql server loaded...Can I somehow point one machine to
the
> second machines SQL server such that we are working on the same database?
> Any ideas/suggestions'

Mapped Drive

Can I make my "default location" for new databases be a mapped drive? When
I go into the properties and select the database tab and select the ...
box to list my drives, the shared drive does not show up. If I go ahead
and enter the path of where I want the files to be located on the "mapped"
drive, it accepts it, but does not use it when I create a new database.
My situation is I have 2 computers in a single room and I want then to be
pointed at the same file location for all databases... Both machines have
MSDE version of sql server loaded...Can I somehow point one machine to the
second machines SQL server such that we are working on the same database?
Any ideas/suggestions'> MSDE version of sql server loaded...Can I somehow point one machine to
the
> second machines SQL server such that we are working on the same database?
I don't think you can share databases between engines (even between
instances on the same machine).
Why not just point one machine's client tools to the other machine's SQL
Server? Then one machine will be working locally, and the other will be
working "remotely" so to speak. But they will be working on the same copy
of exactly one database.
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/|||No.
First, SQL does not support mapped drives for database or transaction log
files.
Second, when SQL does open a database file, it is completely exclusive for
that server instance. Even a second instance on the same host nod could not
access the same underlying database files.
--
Geoff N. Hiten
Microsoft SQL Server MVP
Senior Database Administrator
Careerbuilder.com
I support the Professional Association for SQL Server
www.sqlpass.org
"Jim Heavey" <JHeavey@.nospam.com> wrote in message
news:Xns9495971974DBBJHeaveyBDUP@.207.46.248.16...
> Can I make my "default location" for new databases be a mapped drive?
When
> I go into the properties and select the database tab and select the ...
> box to list my drives, the shared drive does not show up. If I go ahead
> and enter the path of where I want the files to be located on the "mapped"
> drive, it accepts it, but does not use it when I create a new database.
> My situation is I have 2 computers in a single room and I want then to be
> pointed at the same file location for all databases... Both machines
have
> MSDE version of sql server loaded...Can I somehow point one machine to
the
> second machines SQL server such that we are working on the same database?
> Any ideas/suggestions'

Monday, March 26, 2012

MAPI Error 22022 in SQL Server 2000

When I try to test the ability to send e-mail to an operator on one of my servers by opening up the properties for the operator and clicking the "test" button, I get the following error:

"Error 22022: SQLServerAgent Error: MAPI error: Table too big."

Has anyone encountered this? What's the resolution?

Can you log in to the server using the same account that the SQL Server Agent is using and send emails that way? If so, try deleting and recreating the pst file for that user.

BTW - you'll likely receive more feedback from another group. This one is dedicated to Notification Services, which despite the similar sounding name, is a completely different technology.

HTH...

Joesql

MAPI Error 22022 in SQL Server 2000

When I try to test the ability to send e-mail to an operator on one of my servers by opening up the properties for the operator and clicking the "test" button, I get the following error:

"Error 22022: SQLServerAgent Error: MAPI error: Table too big."

Has anyone encountered this? What's the resolution?

Can you log in to the server using the same account that the SQL Server Agent is using and send emails that way? If so, try deleting and recreating the pst file for that user.

BTW - you'll likely receive more feedback from another group. This one is dedicated to Notification Services, which despite the similar sounding name, is a completely different technology.

HTH...

Joe

Wednesday, March 21, 2012

manualy

Hi
In replication shedule properties i gave the option continuesly,i think what
ever modifications we made same time it will replicate.with out setting any
time period how can i do the replication manualy.
Thanks
In the distribution (or merge) agent's job schedule change the option from
'Start automatically when SQL Server agent starts' to 'Recurring' which'll
allow you to specify a schedule.
HTH
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)

Friday, March 9, 2012

Managing user-defined properties for report items

[crossposted to MS Community forums as well]
I have defined a user-defined property for several reports. The coding
for GetProperty/SetProperty is straightforward, but it looks as if
there is no management/admin capability through Report Manager or SQL
Management Studio for user-defined properties. Is this correct?
If that capability does not exist, Is there any plan for future
versions of RM/SqlMgtStudio to support getting/setting user-defined
properties?
Thanks!
Regards,
MichaelJust to follow up on this - I've submitted this as a product request to
Microsoft - they've basically postponed any action on it and said
they'll look at it for a future release. *shrug*
Michael