Showing posts with label writing. Show all posts
Showing posts with label writing. Show all posts

Sunday, March 25, 2012

Advice needed

I have an sql server db on a remote dedicated server that is open on
internet, for remote report writing.
The company that uses is it extremely large and well known, due to this the
sql server gets hammered by bogus logins.
10,000+ of them a day,.
Security wise its ok but the bloody error log files are huge 27-48 mb.
Because I logonto this server remotely atleast once a day and check logs, I
am finding it difficult to read them due to the size for vieving log file
in a TS session.
How can I create 1 error log a day for 7 days then recycle them, or atleast
create them into more manageble sizes.
Regards
DonIf your talking about the Sql Server logs then you can use
sp_cycle_errorlog.
Andrew J. Kelly
SQL Server MVP
"Don Grover" <spamfree@.assoft.com.au> wrote in message
news:e$C62CazDHA.1736@.TK2MSFTNGP09.phx.gbl...
quote:

> I have an sql server db on a remote dedicated server that is open on
> internet, for remote report writing.
> The company that uses is it extremely large and well known, due to this

the
quote:

> sql server gets hammered by bogus logins.
> 10,000+ of them a day,.
> Security wise its ok but the bloody error log files are huge 27-48 mb.
> Because I logonto this server remotely atleast once a day and check logs,

I
quote:

> am finding it difficult to read them due to the size for vieving log file
> in a TS session.
> How can I create 1 error log a day for 7 days then recycle them, or

atleast
quote:

> create them into more manageble sizes.
> Regards
> Don
>

Advice about database deployment

Hello All,
I am writing a database application that will serve multiple companies,
each company contains users that will store/retrieve data from the database.
I am in the process of deciding whether I should have one big database
that stores data for all users of all companies or have a separate
database for each company.
What would be the advantage/disadvantage of selecting one over the other
with the following considerations?
Considerations:
1. failover support
2. performance
3. load balancing via adding multiple database servers
4. clustering
5. backup (full and incremental)
6. database upgrade (eg. adding more tables and relationships, modifying
tables and relationships)
7. special equipment considerations
Any advised would be greatly appreciated.
Thanks in advanced
Hi
Both methods have their advantages and disadvantages so you will have to
weigh up the pros and cons to make a discission. Having a single database may
be ruled out because of security reasons (in fact having databases on the
same instance may be ruled out!) , but it will ease the management and
upgrades. Having single databases will allow you to tailor the databases to
specific requirements and (say) adjust intensive tasks so they don't overload
the system e.g. spread out the backups and other maintenance tasks. Having
separate databases would potentially limit the scope of any mistake (e.g. if
someone managed to take an exclusive lock on a table the impact would be
within a single company not other possibly unrelated companies who could sue
you!).
Hardware clustering should not be affected by either configuration, although
if you are using SQL 2005 and database mirroring you could fail over one
different databases separately and mix the primary instances in similar way
to having multiple instance on a clustered server.
HTH
John
"buzlite@.sympatico.ca" wrote:

> Hello All,
> I am writing a database application that will serve multiple companies,
> each company contains users that will store/retrieve data from the database.
> I am in the process of deciding whether I should have one big database
> that stores data for all users of all companies or have a separate
> database for each company.
> What would be the advantage/disadvantage of selecting one over the other
> with the following considerations?
> Considerations:
> --
> 1. failover support
> 2. performance
> 3. load balancing via adding multiple database servers
> 4. clustering
> 5. backup (full and incremental)
> 6. database upgrade (eg. adding more tables and relationships, modifying
> tables and relationships)
> 7. special equipment considerations
> Any advised would be greatly appreciated.
> Thanks in advanced
>
|||Hi
In addition to John's reply ,I'd ask you ,how big will be databases? Have
you considered to install SQL Server 2005 Express Edition on the company's
site?
It depends on your business requirement , thus there is no common scenario
<buzlite@.sympatico.ca> wrote in message
news:%23Atf%236kCHHA.3916@.TK2MSFTNGP06.phx.gbl...
> Hello All,
> I am writing a database application that will serve multiple companies,
> each company contains users that will store/retrieve data from the
> database.
> I am in the process of deciding whether I should have one big database
> that stores data for all users of all companies or have a separate
> database for each company.
> What would be the advantage/disadvantage of selecting one over the other
> with the following considerations?
> Considerations:
> --
> 1. failover support
> 2. performance
> 3. load balancing via adding multiple database servers
> 4. clustering
> 5. backup (full and incremental)
> 6. database upgrade (eg. adding more tables and relationships, modifying
> tables and relationships)
> 7. special equipment considerations
> Any advised would be greatly appreciated.
> Thanks in advanced
|||On Fri, 17 Nov 2006 08:46:13 -0500, "buzlite@.sympatico.ca"
<buzlite@.sympatico.ca> wrote:

>Hello All,
>I am writing a database application that will serve multiple companies,
>each company contains users that will store/retrieve data from the database.
>I am in the process of deciding whether I should have one big database
>that stores data for all users of all companies or have a separate
>database for each company.
>What would be the advantage/disadvantage of selecting one over the other
>with the following considerations?
>Considerations:
>--
>1. failover support
>2. performance
>3. load balancing via adding multiple database servers
>4. clustering
>5. backup (full and incremental)
>6. database upgrade (eg. adding more tables and relationships, modifying
>tables and relationships)
>7. special equipment considerations
>Any advised would be greatly appreciated.
>Thanks in advanced
* Impact of company-X on the performance of company-Y's operations.
Given a choice like this, perhaps the answer is: both.
Write it for one database for better sharing, it's probably easier to
un-share later, than to add the sharing. Easier to do any
consolidations, when they're on one database, of course.
Then you can deploy it all on one system/instance or on N
systems/instances, if one of the big companies decides they want their
own servers after all.
J.
|||I would say that the data and amount of data from one company could be
pretty large. Given that images can be uploaded to the database in
addition to text.
Given a previous reply to this posting and the fact that large amounts
of data can be produce by any or all given companies, the performance
degradation related factor is indeed a point that needs to be considered.
Thanks
Uri Dimant wrote:
> Hi
> In addition to John's reply ,I'd ask you ,how big will be databases? Have
> you considered to install SQL Server 2005 Express Edition on the company's
> site?
> It depends on your business requirement , thus there is no common scenario
>
>
> <buzlite@.sympatico.ca> wrote in message
> news:%23Atf%236kCHHA.3916@.TK2MSFTNGP06.phx.gbl...
>
|||To Add to the original post, what would the impact of using one database
for all companies and one database instance for each company as it
relates to the following:
Full backups
Transaction log backups
Rebuilding indexes
Integrity Check
buzlite@.sympatico.ca wrote:
> Hello All,
> I am writing a database application that will serve multiple companies,
> each company contains users that will store/retrieve data from the
> database.
> I am in the process of deciding whether I should have one big database
> that stores data for all users of all companies or have a separate
> database for each company.
> What would be the advantage/disadvantage of selecting one over the other
> with the following considerations?
> Considerations:
> --
> 1. failover support
> 2. performance
> 3. load balancing via adding multiple database servers
> 4. clustering
> 5. backup (full and incremental)
> 6. database upgrade (eg. adding more tables and relationships, modifying
> tables and relationships)
> 7. special equipment considerations
> Any advised would be greatly appreciated.
> Thanks in advanced

Advice about database deployment

Hello All,
I am writing a database application that will serve multiple companies,
each company contains users that will store/retrieve data from the database.
I am in the process of deciding whether I should have one big database
that stores data for all users of all companies or have a separate
database for each company.
What would be the advantage/disadvantage of selecting one over the other
with the following considerations?
Considerations:
--
1. failover support
2. performance
3. load balancing via adding multiple database servers
4. clustering
5. backup (full and incremental)
6. database upgrade (eg. adding more tables and relationships, modifying
tables and relationships)
7. special equipment considerations
Any advised would be greatly appreciated.
Thanks in advancedHi
Both methods have their advantages and disadvantages so you will have to
weigh up the pros and cons to make a discission. Having a single database ma
y
be ruled out because of security reasons (in fact having databases on the
same instance may be ruled out!) , but it will ease the management and
upgrades. Having single databases will allow you to tailor the databases to
specific requirements and (say) adjust intensive tasks so they don't overloa
d
the system e.g. spread out the backups and other maintenance tasks. Having
separate databases would potentially limit the scope of any mistake (e.g. if
someone managed to take an exclusive lock on a table the impact would be
within a single company not other possibly unrelated companies who could sue
you!).
Hardware clustering should not be affected by either configuration, although
if you are using SQL 2005 and database mirroring you could fail over one
different databases separately and mix the primary instances in similar way
to having multiple instance on a clustered server.
HTH
John
"buzlite@.sympatico.ca" wrote:

> Hello All,
> I am writing a database application that will serve multiple companies,
> each company contains users that will store/retrieve data from the databas
e.
> I am in the process of deciding whether I should have one big database
> that stores data for all users of all companies or have a separate
> database for each company.
> What would be the advantage/disadvantage of selecting one over the other
> with the following considerations?
> Considerations:
> --
> 1. failover support
> 2. performance
> 3. load balancing via adding multiple database servers
> 4. clustering
> 5. backup (full and incremental)
> 6. database upgrade (eg. adding more tables and relationships, modifying
> tables and relationships)
> 7. special equipment considerations
> Any advised would be greatly appreciated.
> Thanks in advanced
>|||Hi
In addition to John's reply ,I'd ask you ,how big will be databases? Have
you considered to install SQL Server 2005 Express Edition on the company's
site?
It depends on your business requirement , thus there is no common scenario
<buzlite@.sympatico.ca> wrote in message
news:%23Atf%236kCHHA.3916@.TK2MSFTNGP06.phx.gbl...
> Hello All,
> I am writing a database application that will serve multiple companies,
> each company contains users that will store/retrieve data from the
> database.
> I am in the process of deciding whether I should have one big database
> that stores data for all users of all companies or have a separate
> database for each company.
> What would be the advantage/disadvantage of selecting one over the other
> with the following considerations?
> Considerations:
> --
> 1. failover support
> 2. performance
> 3. load balancing via adding multiple database servers
> 4. clustering
> 5. backup (full and incremental)
> 6. database upgrade (eg. adding more tables and relationships, modifying
> tables and relationships)
> 7. special equipment considerations
> Any advised would be greatly appreciated.
> Thanks in advanced|||On Fri, 17 Nov 2006 08:46:13 -0500, "buzlite@.sympatico.ca"
<buzlite@.sympatico.ca> wrote:

>Hello All,
>I am writing a database application that will serve multiple companies,
>each company contains users that will store/retrieve data from the database
.
>I am in the process of deciding whether I should have one big database
>that stores data for all users of all companies or have a separate
>database for each company.
>What would be the advantage/disadvantage of selecting one over the other
>with the following considerations?
>Considerations:
>--
>1. failover support
>2. performance
>3. load balancing via adding multiple database servers
>4. clustering
>5. backup (full and incremental)
>6. database upgrade (eg. adding more tables and relationships, modifying
>tables and relationships)
>7. special equipment considerations
>Any advised would be greatly appreciated.
>Thanks in advanced
* Impact of company-X on the performance of company-Y's operations.
Given a choice like this, perhaps the answer is: both.
Write it for one database for better sharing, it's probably easier to
un-share later, than to add the sharing. Easier to do any
consolidations, when they're on one database, of course.
Then you can deploy it all on one system/instance or on N
systems/instances, if one of the big companies decides they want their
own servers after all.
J.|||I would say that the data and amount of data from one company could be
pretty large. Given that images can be uploaded to the database in
addition to text.
Given a previous reply to this posting and the fact that large amounts
of data can be produce by any or all given companies, the performance
degradation related factor is indeed a point that needs to be considered.
Thanks
Uri Dimant wrote:
> Hi
> In addition to John's reply ,I'd ask you ,how big will be databases? Have
> you considered to install SQL Server 2005 Express Edition on the company's
> site?
> It depends on your business requirement , thus there is no common scenari
o
>
>
> <buzlite@.sympatico.ca> wrote in message
> news:%23Atf%236kCHHA.3916@.TK2MSFTNGP06.phx.gbl...
>|||To Add to the original post, what would the impact of using one database
for all companies and one database instance for each company as it
relates to the following:
Full backups
Transaction log backups
Rebuilding indexes
Integrity Check
buzlite@.sympatico.ca wrote:
> Hello All,
> I am writing a database application that will serve multiple companies,
> each company contains users that will store/retrieve data from the
> database.
> I am in the process of deciding whether I should have one big database
> that stores data for all users of all companies or have a separate
> database for each company.
> What would be the advantage/disadvantage of selecting one over the other
> with the following considerations?
> Considerations:
> --
> 1. failover support
> 2. performance
> 3. load balancing via adding multiple database servers
> 4. clustering
> 5. backup (full and incremental)
> 6. database upgrade (eg. adding more tables and relationships, modifying
> tables and relationships)
> 7. special equipment considerations
> Any advised would be greatly appreciated.
> Thanks in advanced

Advice about database deployment

Hello All,
I am writing a database application that will serve multiple companies,
each company contains users that will store/retrieve data from the database.
I am in the process of deciding whether I should have one big database
that stores data for all users of all companies or have a separate
database for each company.
What would be the advantage/disadvantage of selecting one over the other
with the following considerations?
Considerations:
--
1. failover support
2. performance
3. load balancing via adding multiple database servers
4. clustering
5. backup (full and incremental)
6. database upgrade (eg. adding more tables and relationships, modifying
tables and relationships)
7. special equipment considerations
Any advised would be greatly appreciated.
Thanks in advancedHi
Both methods have their advantages and disadvantages so you will have to
weigh up the pros and cons to make a discission. Having a single database may
be ruled out because of security reasons (in fact having databases on the
same instance may be ruled out!) , but it will ease the management and
upgrades. Having single databases will allow you to tailor the databases to
specific requirements and (say) adjust intensive tasks so they don't overload
the system e.g. spread out the backups and other maintenance tasks. Having
separate databases would potentially limit the scope of any mistake (e.g. if
someone managed to take an exclusive lock on a table the impact would be
within a single company not other possibly unrelated companies who could sue
you!).
Hardware clustering should not be affected by either configuration, although
if you are using SQL 2005 and database mirroring you could fail over one
different databases separately and mix the primary instances in similar way
to having multiple instance on a clustered server.
HTH
John
"buzlite@.sympatico.ca" wrote:
> Hello All,
> I am writing a database application that will serve multiple companies,
> each company contains users that will store/retrieve data from the database.
> I am in the process of deciding whether I should have one big database
> that stores data for all users of all companies or have a separate
> database for each company.
> What would be the advantage/disadvantage of selecting one over the other
> with the following considerations?
> Considerations:
> --
> 1. failover support
> 2. performance
> 3. load balancing via adding multiple database servers
> 4. clustering
> 5. backup (full and incremental)
> 6. database upgrade (eg. adding more tables and relationships, modifying
> tables and relationships)
> 7. special equipment considerations
> Any advised would be greatly appreciated.
> Thanks in advanced
>|||Hi
In addition to John's reply ,I'd ask you ,how big will be databases? Have
you considered to install SQL Server 2005 Express Edition on the company's
site?
It depends on your business requirement , thus there is no common scenario
<buzlite@.sympatico.ca> wrote in message
news:%23Atf%236kCHHA.3916@.TK2MSFTNGP06.phx.gbl...
> Hello All,
> I am writing a database application that will serve multiple companies,
> each company contains users that will store/retrieve data from the
> database.
> I am in the process of deciding whether I should have one big database
> that stores data for all users of all companies or have a separate
> database for each company.
> What would be the advantage/disadvantage of selecting one over the other
> with the following considerations?
> Considerations:
> --
> 1. failover support
> 2. performance
> 3. load balancing via adding multiple database servers
> 4. clustering
> 5. backup (full and incremental)
> 6. database upgrade (eg. adding more tables and relationships, modifying
> tables and relationships)
> 7. special equipment considerations
> Any advised would be greatly appreciated.
> Thanks in advanced|||On Fri, 17 Nov 2006 08:46:13 -0500, "buzlite@.sympatico.ca"
<buzlite@.sympatico.ca> wrote:
>Hello All,
>I am writing a database application that will serve multiple companies,
>each company contains users that will store/retrieve data from the database.
>I am in the process of deciding whether I should have one big database
>that stores data for all users of all companies or have a separate
>database for each company.
>What would be the advantage/disadvantage of selecting one over the other
>with the following considerations?
>Considerations:
>--
>1. failover support
>2. performance
>3. load balancing via adding multiple database servers
>4. clustering
>5. backup (full and incremental)
>6. database upgrade (eg. adding more tables and relationships, modifying
>tables and relationships)
>7. special equipment considerations
>Any advised would be greatly appreciated.
>Thanks in advanced
* Impact of company-X on the performance of company-Y's operations.
Given a choice like this, perhaps the answer is: both.
Write it for one database for better sharing, it's probably easier to
un-share later, than to add the sharing. Easier to do any
consolidations, when they're on one database, of course.
Then you can deploy it all on one system/instance or on N
systems/instances, if one of the big companies decides they want their
own servers after all.
J.|||I would say that the data and amount of data from one company could be
pretty large. Given that images can be uploaded to the database in
addition to text.
Given a previous reply to this posting and the fact that large amounts
of data can be produce by any or all given companies, the performance
degradation related factor is indeed a point that needs to be considered.
Thanks
Uri Dimant wrote:
> Hi
> In addition to John's reply ,I'd ask you ,how big will be databases? Have
> you considered to install SQL Server 2005 Express Edition on the company's
> site?
> It depends on your business requirement , thus there is no common scenario
>
>
> <buzlite@.sympatico.ca> wrote in message
> news:%23Atf%236kCHHA.3916@.TK2MSFTNGP06.phx.gbl...
>> Hello All,
>> I am writing a database application that will serve multiple companies,
>> each company contains users that will store/retrieve data from the
>> database.
>> I am in the process of deciding whether I should have one big database
>> that stores data for all users of all companies or have a separate
>> database for each company.
>> What would be the advantage/disadvantage of selecting one over the other
>> with the following considerations?
>> Considerations:
>> --
>> 1. failover support
>> 2. performance
>> 3. load balancing via adding multiple database servers
>> 4. clustering
>> 5. backup (full and incremental)
>> 6. database upgrade (eg. adding more tables and relationships, modifying
>> tables and relationships)
>> 7. special equipment considerations
>> Any advised would be greatly appreciated.
>> Thanks in advanced
>|||To Add to the original post, what would the impact of using one database
for all companies and one database instance for each company as it
relates to the following:
Full backups
Transaction log backups
Rebuilding indexes
Integrity Check
buzlite@.sympatico.ca wrote:
> Hello All,
> I am writing a database application that will serve multiple companies,
> each company contains users that will store/retrieve data from the
> database.
> I am in the process of deciding whether I should have one big database
> that stores data for all users of all companies or have a separate
> database for each company.
> What would be the advantage/disadvantage of selecting one over the other
> with the following considerations?
> Considerations:
> --
> 1. failover support
> 2. performance
> 3. load balancing via adding multiple database servers
> 4. clustering
> 5. backup (full and incremental)
> 6. database upgrade (eg. adding more tables and relationships, modifying
> tables and relationships)
> 7. special equipment considerations
> Any advised would be greatly appreciated.
> Thanks in advanced

Monday, March 19, 2012

Advanced SQL script Editor

All,
Who and how writes very long scripts in T-SQL? Do we have anything more
convenient than M$ SQL Query Analyzer? I finally started writing my scripts
in WinWord because of the terrible despair. It at least allows me to use
formatting, color selection, block separation, etc. Then I can copy/paste
this script into SQL Query Analyzer to check if it's correct. I realize that
it's crazy, but the Visual Studio IDE, regarding to the T-SQL scripts, is a
simple plain editor, I can't hide blocks, I can't use colors, nothing that I
can do for C#. The long script finally becomes a mess, terrible plain text
unreadable or very hardly readable. I'm talking about the very long scripts
including some general logic, variables, counters, etc., the length of such
a script can be a few thousand lines of the formatted SQL code.
Any advice?
Just D.> a script can be a few thousand lines of the formatted SQL code.
Well that is your fist and biggest mistake. TSQL is not a programming
language and should not be long and drawn out. At the very least break it
down into several manageable stored procedures. This is optimized for SET
based processing of data which should not take 1000 lines of code or more.
Andrew J. Kelly SQL MVP
"Just D." <no@.spam.please> wrote in message
news:LtHXe.131841$Ji4.30207@.fed1read03...
> All,
> Who and how writes very long scripts in T-SQL? Do we have anything more
> convenient than M$ SQL Query Analyzer? I finally started writing my
> scripts in WinWord because of the terrible despair. It at least allows me
> to use formatting, color selection, block separation, etc. Then I can
> copy/paste this script into SQL Query Analyzer to check if it's correct. I
> realize that it's crazy, but the Visual Studio IDE, regarding to the T-SQL
> scripts, is a simple plain editor, I can't hide blocks, I can't use
> colors, nothing that I can do for C#. The long script finally becomes a
> mess, terrible plain text unreadable or very hardly readable. I'm talking
> about the very long scripts including some general logic, variables,
> counters, etc., the length of such a script can be a few thousand lines of
> the formatted SQL code.
> Any advice?
> Just D.
>|||Ok,
Let's ask how to write a 1000-line T-SQL code in the most convenient way.
You suppose that I'd better call the SP from this SP or Trigger using EXEC
etc.? And how fast it should run? Another one bottle neck is the parameters
that in case of EXEC SP should be stored somewhere and sent to this SP, then
something returned back. It will not increase the speed of the script
itself.
Just D.
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:ehG$XDXvFHA.724@.TK2MSFTNGP14.phx.gbl...
> Well that is your fist and biggest mistake. TSQL is not a programming
> language and should not be long and drawn out. At the very least break it
> down into several manageable stored procedures. This is optimized for
> SET based processing of data which should not take 1000 lines of code or
> more.
> --
> Andrew J. Kelly SQL MVP
>
> "Just D." <no@.spam.please> wrote in message
> news:LtHXe.131841$Ji4.30207@.fed1read03...
>|||Just,
Stored procedures are faster. The reduce the overall network traffic for
each call and optimize the execution for subsequent calls on the SQL Server.
HTH
Jerry
"Just D." <no@.spam.please> wrote in message
news:XZHXe.131843$Ji4.74359@.fed1read03...
> Ok,
> Let's ask how to write a 1000-line T-SQL code in the most convenient way.
> You suppose that I'd better call the SP from this SP or Trigger using EXEC
> etc.? And how fast it should run? Another one bottle neck is the
> parameters that in case of EXEC SP should be stored somewhere and sent to
> this SP, then something returned back. It will not increase the speed of
> the script itself.
> Just D.
> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> news:ehG$XDXvFHA.724@.TK2MSFTNGP14.phx.gbl...
>|||Maybe I didn't explain correctly, the script should work itself as a SP or a
Trigger, so it will be compiled and optimized.
"Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
news:eyfR%23QXvFHA.3556@.TK2MSFTNGP12.phx.gbl...
> Just,
> Stored procedures are faster. The reduce the overall network traffic for
> each call and optimize the execution for subsequent calls on the SQL
> Server.
> HTH
> Jerry
> "Just D." <no@.spam.please> wrote in message
> news:XZHXe.131843$Ji4.74359@.fed1read03...
>|||I guess the first question that comes to my mind is what are you trying
to do that requires such a lengthy script? As Andrew pointed out,
T-SQL is optimized for set-based solutions (ie., doing a lot of things
at one time) as opposed to a procedural programming language. It
sounds as if (based on your short description) you're trying to write a
step-by-step operation. In most cases, there is another way, but
without knowing what you are attempting to do, that's a difficult call.
As far as your first question, I don't know of any better editor than
query analyzer. But I do think that having a master procedure call a
series of sub-procedures is one method of breaking your code up into
easily editable sections.
So, what are you trying to do?
Stu|||Xref: TK2MSFTNGP08.phx.gbl microsoft.public.sqlserver.programming:553583
This task has already been working as a SP in a scheduled job every n
minutes and survived for longer than a year. I just need to rewrite it
because the format of the database is modified and it should be reflected in
the local trigger itself. What exactly..? Just a sync script that uploads
the data from one db to another db. Could be simple if the format of these
DBs was equal, but not in this case, I need to transfer different types of
data converting then and the calls themselves to be accepted by the target
database. The best way to go for us was using a scheduled job. I would not
like a system service doing these things or some external app, it's my way
to go, suppose not discussible here. But we have already forgotten the first
question. And I suppose that if there is no ideas it's better to skip the
question instead of starting this discussion in a different direction.
Thanks,
Just D.
"Stu" <stuart.ainsworth@.gmail.com> wrote in message
news:1127173889.928153.17340@.z14g2000cwz.googlegroups.com...
>I guess the first question that comes to my mind is what are you trying
> to do that requires such a lengthy script? As Andrew pointed out,
> T-SQL is optimized for set-based solutions (ie., doing a lot of things
> at one time) as opposed to a procedural programming language. It
> sounds as if (based on your short description) you're trying to write a
> step-by-step operation. In most cases, there is another way, but
> without knowing what you are attempting to do, that's a difficult call.
> As far as your first question, I don't know of any better editor than
> query analyzer. But I do think that having a master procedure call a
> series of sub-procedures is one method of breaking your code up into
> easily editable sections.
> So, what are you trying to do?
> Stu
>|||Not to keep beating a dead horse, but have you considered DTS for the
basis of your job? It's much more flexible for data transformation (as
you describe), and it's usually faster than running a stored procedure
to do complex transformations.
I don't think that anyone has forgotten your first question, btw; it's
just that most of us have a belief that you should use the right tool
for the job. In most cases, T-SQL is not the best choice for complex
procedural transformations; there are exceptions, but they should
remain exceptions.
I'll get off my soapbox now; I'm not trying to lecture you, but I
didn't want you to walk away thinking that your question went
unanswered. It may be that it's not the best approach.
Stu|||You know, maybe you're right, but the solution was written so far ago and
still exists and even works. Maybe Sybase ASA or ASE with its built-in
synchronization is much better, I know enough about it, but sometimes we're
not choosing or even taking a tool, we're just using it. Yes, I got a
Licensed box with ASA9 from Sybase that they presented me for the critical
bug that I found in their mobile engine, I'm still sure that Sybase is the
best appropriate database for what I'm doing now, but keeping the point and
being in this newsgroup where Sybase definitely is off-topic, it's better to
skip that as well. Finally we're not responsible for the clients whose data
I'm syncing now. And this is a problem, not so huge, but solvable using
different approaches, that I'm doing right now.
Thanks,
Just D.
"Stu" <stuart.ainsworth@.gmail.com> wrote in message
news:1127176774.800960.61880@.f14g2000cwb.googlegroups.com...
> Not to keep beating a dead horse, but have you considered DTS for the
> basis of your job? It's much more flexible for data transformation (as
> you describe), and it's usually faster than running a stored procedure
> to do complex transformations.
> I don't think that anyone has forgotten your first question, btw; it's
> just that most of us have a belief that you should use the right tool
> for the job. In most cases, T-SQL is not the best choice for complex
> procedural transformations; there are exceptions, but they should
> remain exceptions.
> I'll get off my soapbox now; I'm not trying to lecture you, but I
> didn't want you to walk away thinking that your question went
> unanswered. It may be that it's not the best approach.
> Stu
>|||This link might help; certainly on topic : - )
[url]http://www.dba.com/[/url]
"Just D." <no@.spam.please> wrote in message
news:jhJXe.131850$Ji4.111606@.fed1read03...
> You know, maybe you're right, but the solution was written so far ago and
> still exists and even works. Maybe Sybase ASA or ASE with its built-in
> synchronization is much better, I know enough about it, but sometimes
> we're not choosing or even taking a tool, we're just using it. Yes, I got
> a Licensed box with ASA9 from Sybase that they presented me for the
> critical bug that I found in their mobile engine, I'm still sure that
> Sybase is the best appropriate database for what I'm doing now, but
> keeping the point and being in this newsgroup where Sybase definitely is
> off-topic, it's better to skip that as well. Finally we're not responsible
> for the clients whose data I'm syncing now. And this is a problem, not so
> huge, but solvable using different approaches, that I'm doing right now.
> Thanks,
> Just D.
>
> "Stu" <stuart.ainsworth@.gmail.com> wrote in message
> news:1127176774.800960.61880@.f14g2000cwb.googlegroups.com...
>

Advanced sort

I need some help writing this sql query.
I have three columns in my table
let call them
tOrderA,tOrderB,tContent
tOrderA,tOrderB are random integers from 1-10 000, tContent is a text field
so my table looks something like this
|tOrderA|tOrderB|tContent|
1 27 my
9 3 asfdf
152 16 sdfsd
18 22 dfdf
182 14 dfdsfs
tOrderA is my primary sort with levels (ie.1-100,101-200,201-300)
tOrderB is my secondary sort.
when the sort is applied the table should look like this.
|tOrderA|tOrderB|tContent|
9 3 asfdf
18 22 dfdf
1 27 my
182 14 dfdsfs
152 16 sdfsd
How would I write this query?
select tContent from tableA order by tOrderA ASC [range
1-100,101-200,201-300...] and tOrderB ASC
Thanks,
Aaronselect tOrderA, tOrderB, tContent
from tableA
order by (tOrderA + 1) / 100, tOrderB
"Aaron" wrote:

> I need some help writing this sql query.
> I have three columns in my table
> let call them
> tOrderA,tOrderB,tContent
> tOrderA,tOrderB are random integers from 1-10 000, tContent is a text fiel
d
> so my table looks something like this
> |tOrderA|tOrderB|tContent|
> 1 27 my
> 9 3 asfdf
> 152 16 sdfsd
> 18 22 dfdf
> 182 14 dfdsfs
>
> tOrderA is my primary sort with levels (ie.1-100,101-200,201-300)
> tOrderB is my secondary sort.
> when the sort is applied the table should look like this.
> |tOrderA|tOrderB|tContent|
> 9 3 asfdf
> 18 22 dfdf
> 1 27 my
> 182 14 dfdsfs
> 152 16 sdfsd
> How would I write this query?
> select tContent from tableA order by tOrderA ASC [range
> 1-100,101-200,201-300...] and tOrderB ASC
>
> Thanks,
> Aaron
>
>|||You mean:
select tOrderA, tOrderB, tContent
from tableA
order by (tOrderA - 1) / 100, tOrderB
^^^^^
With your code 99 and 100 will be in the [101 - 200] bracket.
Jacco Schalkwijk
SQL Server MVP
"CBretana" <cbretana@.areteIndNOSPAM.com> wrote in message
news:B77956D1-7821-4B24-B0A2-E898FA3B3F48@.microsoft.com...
> select tOrderA, tOrderB, tContent
> from tableA
> order by (tOrderA + 1) / 100, tOrderB
> "Aaron" wrote:
>|||Right ! Thanks! would that be the infamous "off by 2" error '
"Jacco Schalkwijk" wrote:

> You mean:
> select tOrderA, tOrderB, tContent
> from tableA
> order by (tOrderA - 1) / 100, tOrderB
> ^^^^^
> With your code 99 and 100 will be in the [101 - 200] bracket.
> --
> Jacco Schalkwijk
> SQL Server MVP
>
> "CBretana" <cbretana@.areteIndNOSPAM.com> wrote in message
> news:B77956D1-7821-4B24-B0A2-E898FA3B3F48@.microsoft.com...
>
>

Friday, February 24, 2012

ADO.NET OleDb SET ROWCOUNT or DBPROP_MAXROWS

I am writing a data access tool that needs to be non provider specific. I have used System.Data.OleDb to access a variety of data source types (MSSQLServer, MSAccess, MSExcel, CSV, Oracle, XML). This works beautifully. Thankyou Microsoft for giving us ADO.NET2.0.

However, I now need to restrict the number of rows returned from a SELECT statement. Is there any way I can I achieve this in a non provider specific fashion?

So far searches have yielded DBPROP_MAXROWS however I can find no way of setting the DBProperties using ADO.NET2.0. Is this possible?

Documentation for DBPROP_MAXROWS states that it uses "SET ROWCOUNT n" as part of the command text. I tried this and it works but not for the JET4 provider (this is a problem since I use JET4 to access .mdb, .xls and .csv files)!

Any tips here would be greatly appreciated. Even if somebody were to tell me that it's just not possible, at least that would put me out of my misery :)

Thanks.

Because of the way JET accesses data, bringing all of the data to the client before processing the criteria, I don't think that there is a way to make that work.|||

Thanks for the reply Arnie,

since posting I have done some more research and discovered that using TOP works for Jet. This is good for me as it also works for SQL Server. The approach I have taken is as follows:

int maxRows = 100;

string someQry = "SELECT * FROM table1";

string topQry = "SELECT TOP " + maxRows.ToString() + " * FROM (" + someQry + ") as topSubQry";

However it doesn't work for XML files. To get data from XML files I use a connection string of "Provider=MSDAOSP.1;Data Source=MSXML2.DSOControl.2.6;" and then the full path to the XML file as the command text. I am guessing there will just be no way to limit the rows returned when using this provider.

Sunday, February 19, 2012

ADO Performance question

Hi,
I am writing a code which is actually performing multiple inserts on a table
.
Currently I am combining all my insert queries and passing as command text t
o ADO command object.
There is one more way by opening a recordset and call AddNew on recordset mu
ltiple times and then batch update.
But I am not sure which method is better than other and which approach shoul
d I use.
Thanks in advance.
PushkarHi
Why not just calling a stored procedures that does the job?
"Pushkar" <pushkartiwari@.gmail.com> wrote in message news:uA7uMRk2FHA.472@.TK
2MSFTNGP15.phx.gbl...
Hi,
I am writing a code which is actually performing multiple inserts on a table
.
Currently I am combining all my insert queries and passing as command text t
o ADO command object.
There is one more way by opening a recordset and call AddNew on recordset mu
ltiple times and then batch update.
But I am not sure which method is better than other and which approach shoul
d I use.
Thanks in advance.
Pushkar|||If you are inserting 100,000+ records, then calling a Recordset.AddNew for e
ach record will be very slow.
I once wrote an ETL application in VB6.0/ADO2.5 that performed some rather c
omplex data transformations on millions of records per day that were derived
from the mainframe and MS Excel. I would run the app on the local workstati
on, appending each record to a tab delimited text file. When this step compl
eted, I would then bulk copy (BCP.EXE) the resulting file into SQL Server. T
he difference in runtime per batch was a couple of hours vs. 20 minutes. Ano
ther advantage to this is you can run the application on multiple PCs with n
o load on the database server except for the bulk copy operations.
You may also want to try posting to microsoft.public.data.ado
"Pushkar" <pushkartiwari@.gmail.com> wrote in message news:uA7uMRk2FHA.472@.TK
2MSFTNGP15.phx.gbl...
Hi,
I am writing a code which is actually performing multiple inserts on a table
.
Currently I am combining all my insert queries and passing as command text t
o ADO command object.
There is one more way by opening a recordset and call AddNew on recordset mu
ltiple times and then batch update.
But I am not sure which method is better than other and which approach shoul
d I use.
Thanks in advance.
Pushkar|||Batching is generally faster. But you are moving a lot of data across
the network. As Uri mentions, why not use a stored procedure instead
(even if this implies a few calls to the procedure). If you are dealing
with thousands of rows, this might perform better using a bulk insert or
running locally on the server.
David Gugick
Quest Software
www.quest.com
"Pushkar" <pushkartiwari@.gmail.com> wrote in message
news:uA7uMRk2FHA.472@.TK2MSFTNGP15.phx.gbl...
Hi,
I am writing a code which is actually performing multiple inserts on a
table.
Currently I am combining all my insert queries and passing as command
text to ADO command object.
There is one more way by opening a recordset and call AddNew on
recordset multiple times and then batch update.
But I am not sure which method is better than other and which approach
should I use.
Thanks in advance.
Pushkar