显示标签为“ive”的博文。显示所有博文
显示标签为“ive”的博文。显示所有博文

2012年3月29日星期四

BCP/BULK INSERT

Hi everyone,
I have to load data from a .txt file into a database table, I've decided to
use the BULK INSERT command because of the speed it has. At the first phase,
all data from the text file inserted to a temporaly table, which has only
varchar(x) fields, the second phase will process the data.
I have problems with the first phase, some records of the text file are not
well-formed, some fields are missing in several rows (this by design,
unfortunatly).
If the last field is missing, it will be null, as I excepted it.
But, if the the last two (or more) fields are missing, the it seems the
whole line shifted, and BCP starts to read the next row. And, of course, it
produces an error ("String or binary data would be truncated"). If I turn off
the ANSI_WARNINGS, I'll have a lot of false data - because of the "shift".
I'm using format files, all the fields are SQLCHAR by default, all of them
has a correct field length.
You could reproduce the error of course, with the following test script:
if exists(select 1 from sysobjects where name='table1')
begin
drop table table1;
end;
create table table1(
field1 varchar(2),
field2 varchar(2),
field3 varchar(2)
);
go
truncate table table1;
bulk insert table1 from 'table1.txt' with (formatfile='table1.fmt');
select * from table1;
go
The format file:
8.0
3
1 SQLCHAR 0 2 "" 1 field1
Hungarian_CI_AS
2 SQLCHAR 0 2 "" 2 field2
Hungarian_CI_AS
3 SQLCHAR 0 2 "\r\n" 3 field3
Hungarian_CI_AS
The data file:
01AAaa
02BBbb
03CCcc
04DD
05EE
06
07
08HH
09IIii
Has anyone a help or suggestion to resolve this problem? I do not want to
hardcode this process .
Thanks,
Tamas Beri
Hi
Modify it for your needs
1)
select * from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt;
*.csv)};
DefaultDir=D:\myfolder;','select * from data1.txt')
--Text file structure
col1
01AAaa
02BBbb
03CCcc
04DD
05EE
06
07
08HH
09IIii
2)
CREATE TABLE [tt] (
[ModuleID] [int] IDENTITY (1, 1) NOT NULL ,
[field1] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
,
[field2] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
NULL
) ON [PRIMARY]
GO
BULK INSERT tt
FROM 'd:\dat1.txt'
WITH
(
FIRSTROW = 3,
FORMATFILE = 'd:\fmt1.fmt'
)
select * from tt
--Text file structure
field1,field2
01,AAaa
02,BBbb
03,CCcc
04,DD
05,EE
06,
07,
08,HH
09,IIii
--fmt file structure
8.0
2
1 SQLCHAR 0 100 "," 2 field1
SQL_Latin1_General_CP1_CI_AS
2 SQLCHAR 0 10 "\r\n" 3 field2
SQL_Latin1_General_CP1_CI_AS
"gfoyle" <gfoyle@.discussions.microsoft.com> wrote in message
news:2E818698-6ABB-4820-BB41-57BA89477D11@.microsoft.com...
> Hi everyone,
> I have to load data from a .txt file into a database table, I've decided
to
> use the BULK INSERT command because of the speed it has. At the first
phase,
> all data from the text file inserted to a temporaly table, which has only
> varchar(x) fields, the second phase will process the data.
> I have problems with the first phase, some records of the text file are
not
> well-formed, some fields are missing in several rows (this by design,
> unfortunatly).
> If the last field is missing, it will be null, as I excepted it.
> But, if the the last two (or more) fields are missing, the it seems the
> whole line shifted, and BCP starts to read the next row. And, of course,
it
> produces an error ("String or binary data would be truncated"). If I turn
off
> the ANSI_WARNINGS, I'll have a lot of false data - because of the "shift".
> I'm using format files, all the fields are SQLCHAR by default, all of
them
> has a correct field length.
> You could reproduce the error of course, with the following test script:
> if exists(select 1 from sysobjects where name='table1')
> begin
> drop table table1;
> end;
> create table table1(
> field1 varchar(2),
> field2 varchar(2),
> field3 varchar(2)
> );
> go
> truncate table table1;
> bulk insert table1 from 'table1.txt' with (formatfile='table1.fmt');
> select * from table1;
> go
> The format file:
> 8.0
> 3
> 1 SQLCHAR 0 2 "" 1
field1
> Hungarian_CI_AS
> 2 SQLCHAR 0 2 "" 2
field2
> Hungarian_CI_AS
> 3 SQLCHAR 0 2 "\r\n" 3
field3
> Hungarian_CI_AS
> The data file:
> 01AAaa
> 02BBbb
> 03CCcc
> 04DD
> 05EE
> 06
> 07
> 08HH
> 09IIii
> Has anyone a help or suggestion to resolve this problem? I do not want to
> hardcode this process .
> Thanks,
> Tamas Beri
>
|||Thanks,
finally I've decided to read the data in two steps, at first in a temp
table which has only one row, and then the second phase is an insert into
select from with a massive using of substring, cast and case .
Another strange thing, I've tried to create a procedure:
create procedure some_procedure(@.filename varchar(256)) as
begin
bulk insert some_table from @.filename with(codepage='raw');
end;
go
And the creation fails, it says, "Incorrect syntax near '@.filename'.".
?
It is possible to pass the bulk insert command a variable?
Regards,
Tamas Beri
"Uri Dimant" wrote:

> Hi
> Modify it for your needs
> 1)
> select * from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt;
> *.csv)};
> DefaultDir=D:\myfolder;','select * from data1.txt')
> --Text file structure
> col1
> 01AAaa
> 02BBbb
> 03CCcc
> 04DD
> 05EE
> 06
> 07
> 08HH
> 09IIii
> 2)
> CREATE TABLE [tt] (
> [ModuleID] [int] IDENTITY (1, 1) NOT NULL ,
> [field1] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
> ,
> [field2] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
> NULL
> ) ON [PRIMARY]
> GO
>
> BULK INSERT tt
> FROM 'd:\dat1.txt'
> WITH
> (
> FIRSTROW = 3,
> FORMATFILE = 'd:\fmt1.fmt'
> )
> select * from tt
> --Text file structure
> field1,field2
> 01,AAaa
> 02,BBbb
> 03,CCcc
> 04,DD
> 05,EE
> 06,
> 07,
> 08,HH
> 09,IIii
> --fmt file structure
> 8.0
> 2
> 1 SQLCHAR 0 100 "," 2 field1
> SQL_Latin1_General_CP1_CI_AS
> 2 SQLCHAR 0 10 "\r\n" 3 field2
> SQL_Latin1_General_CP1_CI_AS

2012年3月25日星期日

BCP Transaction Does not roll back

Hi All,
I'm trying to import some data using the BCP command line utility.
I've set the maxerrors switch to 0. In case of an exception such as a
cast exception the import fails leaving the table state dirtied.
ie...with partial data imported.
From what I understand from a few other posts the transaction logs
only store the space alocated and not the actual data.
How does one ensure that the import is done in a transaction ?
Any suggestions/ideas will be great.
Regards,
Avinash
Can you post the command you are running
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
"Avinash" <avinashraj@.gmail.com> wrote in message
news:f22f61b0.0412050250.3d6ef381@.posting.google.c om...
> Hi All,
> I'm trying to import some data using the BCP command line utility.
> I've set the maxerrors switch to 0. In case of an exception such as a
> cast exception the import fails leaving the table state dirtied.
> ie...with partial data imported.
> From what I understand from a few other posts the transaction logs
> only store the space alocated and not the actual data.
> How does one ensure that the import is done in a transaction ?
> Any suggestions/ideas will be great.
> Regards,
> Avinash

2012年3月22日星期四

BCP Problem with SQL Server 2000

Ive encountered the following problem when trying to bcp out data
from a table with text columns :
Starting copy...
SQLState = S1001, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Memory allocation failure
Ive no idea on whats going on with it :cry:
Posted using the http://www.dbforumz.com interface, at author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbforumz.com/Server-BCP-P...ict245539.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbforumz.com/eform.php?p=852097
terry_aibo,
Try increasing the size of the windows page file. Also, allow SQL Server
to take as much memory on the machine as possible, something like
(TotalRam-200MB). Try and switch off any unnecessary services, and quit
any running applications except SQL Server. Try and make the machine a
"pure" dedicated SQL Server. Ensure you have the latest service pack.
If this fails to cure it, I would raise a call with Microsoft, this
error is quite rare.
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602m.html
terry_aibo wrote:
> Ive encountered the following problem when trying to bcp out data
> from a table with text columns :
> Starting copy...
> SQLState = S1001, NativeError = 0
> Error = [Microsoft][ODBC SQL Server Driver]Memory allocation failure
>
> Ive no idea on whats going on with it :cry:
>

BCP Problem with SQL Server 2000

Ive encountered the following problem when trying to bcp out data
from a table with text columns :
Starting copy...
SQLState = S1001, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Memory allocation failure
Ive no idea on whats going on with it :cry:
Posted using the http://www.dbforumz.com interface, at author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbforumz.com/Server-BCP-...rm.php?p=852097terry_aibo,
Try increasing the size of the windows page file. Also, allow SQL Server
to take as much memory on the machine as possible, something like
(TotalRam-200MB). Try and switch off any unnecessary services, and quit
any running applications except SQL Server. Try and make the machine a
"pure" dedicated SQL Server. Ensure you have the latest service pack.
If this fails to cure it, I would raise a call with Microsoft, this
error is quite rare.
--
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602m.html
terry_aibo wrote:
> Ive encountered the following problem when trying to bcp out data
> from a table with text columns :
> Starting copy...
> SQLState = S1001, NativeError = 0
> Error = [Microsoft][ODBC SQL Server Driver]Memory allocation failu
re
>
> Ive no idea on whats going on with it :cry:
>

2012年3月11日星期日

Bcp import - how?

I've exported one table using DTS to *.txt file:
"id","name","calories"
{F5F781EF-4270-4D8C-B5E0-A968F45FF771},"Ananas frisch",60
{CA0E96D8-9017-4DDD-BF29-B78D3DC8180D},"Ananas Fruchtnektar",70
{A1777D54-9303-4AF5-A721-250A39BA731C},"Ananas Fruchtsaft",60
{DACC2063-0985-41EB-9A33-B4D8A10F1C79},"Ananas getrocknet",300
{04E462EC-57B1-4882-A8DF-A1EFC1B9C4F3},"Ananas kandiert",250
How can I import this data using bcp? I've tried many combination of
parameters (-q etc.), but the result ist always wrong (that means, I've
imported but fields are filled with no or partial data). Where can I find a
good description of bcp utility with examples (msdn is very poor)?
Thanx in advance,
Adam
Adam Boczek
adam.boczek@.cs-consulting.de
Hi,
Use BULK Insert.
1. I have saved the contents as ccc.txt in drive.
2. Created a table with below script :-
create table zz(id uniqueidentifier,name varchar(30),calories int)
3. Executed the below in query analyzer
BULK INSERT master.dbo.zz
FROM 'c:\ccc.txt'
WITH
(
FIELDTERMINATOR = ','
)
4. select * from zz
id name calories
-- -- --
F5F781EF-4270-4D8C-B5E0-A968F45FF771 "Ananas frisch" 60
CA0E96D8-9017-4DDD-BF29-B78D3DC8180D "Ananas Fruchtnektar" 70
A1777D54-9303-4AF5-A721-250A39BA731C "Ananas Fruchtsaft" 60
DACC2063-0985-41EB-9A33-B4D8A10F1C79 "Ananas getrocknet" 300
04E462EC-57B1-4882-A8DF-A1EFC1B9C4F3 "Ananas kandiert" 250
(5 row(s) affected)
Thanks
Hari
MCDBA
"Adam Boczek" <adam.boczek@.NO_SPAM.cs-consulting.de> wrote in message
news:1086160529.62750@.proxy.ham.cs-consulting.de...
> I've exported one table using DTS to *.txt file:
> "id","name","calories"
> {F5F781EF-4270-4D8C-B5E0-A968F45FF771},"Ananas frisch",60
> {CA0E96D8-9017-4DDD-BF29-B78D3DC8180D},"Ananas Fruchtnektar",70
> {A1777D54-9303-4AF5-A721-250A39BA731C},"Ananas Fruchtsaft",60
> {DACC2063-0985-41EB-9A33-B4D8A10F1C79},"Ananas getrocknet",300
> {04E462EC-57B1-4882-A8DF-A1EFC1B9C4F3},"Ananas kandiert",250
> How can I import this data using bcp? I've tried many combination of
> parameters (-q etc.), but the result ist always wrong (that means, I've
> imported but fields are filled with no or partial data). Where can I find
a
> good description of bcp utility with examples (msdn is very poor)?
> Thanx in advance,
> Adam
> --
> ----
> Adam Boczek
> adam.boczek@.cs-consulting.de
> ----
>

2012年2月13日星期一

Batch file call to SQL Agent to make Bakcup

Hello.
I've a Backup system that copies my files and I want to copy also my
SQL Server DDBB. I intend to execute the batch file before de File
Backup starts to call de SQL Agent so it makes those Backups and then
copy them to the Backup folder so the Backup system copies everything.
The problem is that I don't know if it is possible to call to the SQL
Agent through a Batch file to make these Backups. If so, how could I
do it?
Thank you.
One suggestion ... instead of having the batch file calling the SQL Agent,
you can use the OSQL utility (it is a command line utility for SQL). You can
backup the database using OSQL.
Thank you
Lucas
"Gurk" <gurkgamer@.gmail.com> wrote in message
news:1181666228.803256.267530@.d30g2000prg.googlegr oups.com...
> Hello.
> I've a Backup system that copies my files and I want to copy also my
> SQL Server DDBB. I intend to execute the batch file before de File
> Backup starts to call de SQL Agent so it makes those Backups and then
> copy them to the Backup folder so the Backup system copies everything.
> The problem is that I don't know if it is possible to call to the SQL
> Agent through a Batch file to make these Backups. If so, how could I
> do it?
> Thank you.
>
|||If the backup script is in a job, you can execute that job
through OSQL, SQLCMD, etc by executing sp_start_job. You can
find more information on sp_start_job in books online
-Sue
On Tue, 12 Jun 2007 09:37:08 -0700, Gurk
<gurkgamer@.gmail.com> wrote:

>Hello.
>I've a Backup system that copies my files and I want to copy also my
>SQL Server DDBB. I intend to execute the batch file before de File
>Backup starts to call de SQL Agent so it makes those Backups and then
>copy them to the Backup folder so the Backup system copies everything.
>The problem is that I don't know if it is possible to call to the SQL
>Agent through a Batch file to make these Backups. If so, how could I
>do it?
>Thank you.

2012年2月11日星期六

Basics, just the basics, please (BUMP)

John,
I've bumped this up because I have been so busy on other things that I was
afraid that it would get lost in the other messages...
On my SQL Server, as I had mentioned, I have two Server Groups: (local) and
SVR1/SHAREPOINT. When I try to use the SQL Analyzer to run the EXEC... you
wanted me to run, I cannot "see" the SVR1/SHAREPOINT server group, it will
only allow me to see the (local) one. I'm logging in as 'Administrator' so
I assumed that I should have access to everything. But in the SQL Analyzer
I can't get to it, but in the Enterprise Manager both groups show up.
Oh great guru, what words of wisdom can you impart on this lowly (read
'helpless'), but trying, IT worker?
Thanks for your help,
Rich

>You're welcome, Rich !
>Under your SHAREPOINT named instance of SQL Server, could you run the
>following code and post the result?
>EXEC master..xp_regread 'HKEY_LOCAL_MACHINE',
>'SYSTEM\CurrentControlSet\Services\MSSQL$SHAREPOI NT', 'ObjectName'
>go
>The output Data should be the exact account that this named instance
>(SHAREPOINT) is running under. If it is a local Windows account, this could
>explain why the Full-Text Indexing menu items are grayed out. If so, please
>review KB article Q270671 (Q270671) "PRB: Full Text Search Menus Are Not
>Enabled for Local Windows NT Accounts" at:
>http://support.microsoft.com/default...;en-us;q270671 You should
>test using the system stored procs sp_fulltext_* to see if you can create a
>FT Catalog and run a Full Population. If you can change the SQL Server
named
>instance (SHAREPOINT) startup account to a new or existing DOMAIN\Account
>that is a member of the server's Admin. Group, and not the DOMAIN
>Administrator account (I'm assuming that CMSouth\Administrator is the
Domain
>Admin account) that could solve this issue too.
>Thanks,
>John "Genius" Kane ;-))
"RDavid" <r@.c-m.NOSPAMcomm> wrote in message
news:#9vvgTVhEHA.2908@.TK2MSFTNGP10.phx.gbl...
> John,
> Thanks for your reply. I've got some reading to do, thanks for the lead.
> On the other issue I raised, regarding whether or not two groups would be
> handled as one, you indicated that both would need to have FTS set up
> through the wizard for FTS to take effect.
> The two groups I have are like this:
> Microsoft SQL Servers
> SQL Server Group
> (LOCAL) (Windows NT)
> (SVR1\SHAREPOINT) (Windows NT)
> When I highlight the LOCAL one, I get (under Tools) Full-Text Indexing...
as
> an enabled choice. But when I highlight the SHAREPOINT one, the Full-Text
> Indexing... is greyed out.
> I checked under Security on both and then Logins and both have
> BUILTIN\Administrators (group) and CMSouth\Administrator (user) (CMSouth
is
> the domain name of SVR1). Along with an 'sa' for both.
> Is there something I'm missing here? When I go into the Query Analyzer
and
> it prompts for the server to connect to, it only offers "local" and not
the[vbcol=seagreen]
> SHAREPOINT database group.
> I would appreciate any light you might shed on this.
> Rich
> PS: And yes, I did say genius. Anyone who can understand this as well as
> you deserves that label.
>
>
>
> "John Kane" <jt-kane@.comcast.net> wrote in message
> news:unU3fPMhEHA.3664@.TK2MSFTNGP11.phx.gbl...
reasons[vbcol=seagreen]
> Dummy's"
is[vbcol=seagreen]
> "full
titles[vbcol=seagreen]
for[vbcol=seagreen]
least[vbcol=seagreen]
> and
> schedule
> that
or[vbcol=seagreen]
and[vbcol=seagreen]
in
> *contributor*)
>
http://support.microsoft.com/default...per.asp#enable[vbcol=seagreen]
> SQL
> your
> database
> all
up[vbcol=seagreen]
> externally
not[vbcol=seagreen]
14:22:05[vbcol=seagreen]
> Windows
Dummy's?"[vbcol=seagreen]
> is
> how
or
>
Hi Rich,
Not to worry... as I do actively monitor this newsgroup! Is the server
"SVR1" your local machine or a remote server? If it is local, then should be
able to run the follow EXEC from your (local) server when logged into your
(local) SQL Server as administrator or as sa as all it does is read a
registry key on the local server.
EXEC master..xp_regread 'HKEY_LOCAL_MACHINE',
'SYSTEM\CurrentControlSet\Services\MSSQL$SHAREPOIN T', 'ObjectName'
If SVR1 is not your local machine, could you have someone who has direct
access to the remote server run the above SQL code on the remove server?
Note, (s)he too should be admin or have sa access to that server. This is
less an issue of how you are logged on and more an issue of how the
MSSQLServer service on either your local or remote server is started and
what is the account for that service.
Thanks,
John
"RDavid" <r@.c-m.NOSPAMcomm> wrote in message
news:e$6jtwtjEHA.596@.TK2MSFTNGP11.phx.gbl...
> John,
> I've bumped this up because I have been so busy on other things that I was
> afraid that it would get lost in the other messages...
> On my SQL Server, as I had mentioned, I have two Server Groups: (local)
and
> SVR1/SHAREPOINT. When I try to use the SQL Analyzer to run the EXEC...
you
> wanted me to run, I cannot "see" the SVR1/SHAREPOINT server group, it will
> only allow me to see the (local) one. I'm logging in as 'Administrator'
so
> I assumed that I should have access to everything. But in the SQL
Analyzer[vbcol=seagreen]
> I can't get to it, but in the Enterprise Manager both groups show up.
> Oh great guru, what words of wisdom can you impart on this lowly (read
> 'helpless'), but trying, IT worker?
> Thanks for your help,
> Rich
>
>
could[vbcol=seagreen]
please[vbcol=seagreen]
should[vbcol=seagreen]
a[vbcol=seagreen]
> named
> Domain
>
>
> "RDavid" <r@.c-m.NOSPAMcomm> wrote in message
> news:#9vvgTVhEHA.2908@.TK2MSFTNGP10.phx.gbl...
lead.[vbcol=seagreen]
be[vbcol=seagreen]
Indexing...[vbcol=seagreen]
> as
Full-Text[vbcol=seagreen]
> is
> and
> the
as[vbcol=seagreen]
> reasons
> is
> titles
> for
> least
to[vbcol=seagreen]
Manager[vbcol=seagreen]
own[vbcol=seagreen]
FAQ's[vbcol=seagreen]
> or
> and
are[vbcol=seagreen]
Microsoft
> in
>
http://support.microsoft.com/default...per.asp#enable[vbcol=seagreen]
per[vbcol=seagreen]
both[vbcol=seagreen]
it's[vbcol=seagreen]
ends[vbcol=seagreen]
> up
> not
> 14:22:05
> Dummy's?"
much[vbcol=seagreen]
of[vbcol=seagreen]
> or
and[vbcol=seagreen]
same
>
>
|||Hi John,
I've about had it with this whole mess. I think I'm gonna issue 3x5 index
cards for everyone to just write down information and to heck with SQL
Server.
Okay. The server I've been trying to get FTS running on is about 12 feet
behind me. So I rolled my chair back there and logged off as Administrator
and logged in as myself. When I called Query Analyzer up, it asked for the
connection, so I gave it SVR1/SHAREPOINT and suddenly it just showed me what
it wouldn't show me before. <Grrrrrr>
I ran the EXEC and the response was Data=LocalSystem
So now that I found that out I went to the KB you indicated and read it, and
read it and read it and read it. It makes me think that I might just need a
16 pound sledge hammer instead of only an 8 pound sledge. I guess the
options of dealing with a stored procedure to perform the indexing
(database, table, column, etc) is a matter of review and considerations and
trade offs as far as speed and needs. I need to find the tech-writer for
WSS and have him/her reread the step by step instructions they show to make
FTS work. It isn't any little trivial thing and yet the documentation is
just, 'set this flag and save and voila!' Right, not hardly.
So I need to find out which table/column needs to be searchable and then
plan out which sp_ to use.
Your help has been enormous and I'm very appreciative. I still feel dumb,
but maybe some of this will finally sink in.
Thank you,
Rich
"John Kane" <jt-kane@.comcast.net> wrote in message
news:%23ACDr5tjEHA.3896@.TK2MSFTNGP15.phx.gbl...
> Hi Rich,
> Not to worry... as I do actively monitor this newsgroup! Is the server
> "SVR1" your local machine or a remote server? If it is local, then should
be[vbcol=seagreen]
> able to run the follow EXEC from your (local) server when logged into your
> (local) SQL Server as administrator or as sa as all it does is read a
> registry key on the local server.
> EXEC master..xp_regread 'HKEY_LOCAL_MACHINE',
> 'SYSTEM\CurrentControlSet\Services\MSSQL$SHAREPOIN T', 'ObjectName'
> If SVR1 is not your local machine, could you have someone who has direct
> access to the remote server run the above SQL code on the remove server?
> Note, (s)he too should be admin or have sa access to that server. This is
> less an issue of how you are logged on and more an issue of how the
> MSSQLServer service on either your local or remote server is started and
> what is the account for that service.
> Thanks,
> John
>
>
> "RDavid" <r@.c-m.NOSPAMcomm> wrote in message
> news:e$6jtwtjEHA.596@.TK2MSFTNGP11.phx.gbl...
was[vbcol=seagreen]
> and
> you
will[vbcol=seagreen]
> so
> Analyzer
> could
> please
Not[vbcol=seagreen]
> should
create[vbcol=seagreen]
> a
DOMAIN\Account[vbcol=seagreen]
> lead.
> be
> Indexing...
> Full-Text
(CMSouth[vbcol=seagreen]
Analyzer[vbcol=seagreen]
not[vbcol=seagreen]
> as
start[vbcol=seagreen]
on[vbcol=seagreen]
BOL[vbcol=seagreen]
> to
> Manager
> own
> FAQ's
below)[vbcol=seagreen]
behavior
> are
> Microsoft
>
http://support.microsoft.com/default...per.asp#enable[vbcol=seagreen]
> per
time?[vbcol=seagreen]
> both
> it's
> ends
or[vbcol=seagreen]
Sharepoint[vbcol=seagreen]
> much
root[vbcol=seagreen]
> of
installed
> and
> same
>
|||You're welcome, Rich,
Yea, I hear you and understand your frustration as I once told an ex-SQL PM,
that troubleshooting FTS is like trying to figure out what's on the other
side of a black hole - as in nothing escapes a black hole, not even light -
so it's very difficult to see what's on the other side of a black hole!
Anyways, the fact that the EXEC returned LocalSystem is a good thing... Now,
what I need to understand is how you have the remote server "registered" in
your SQL Server Enterprise Manager. Are you using the machine name or it's
IP address or an alias for the server?
While KB articles are sometimes not easy to understand (even for me and I
wrote a few of them! ;), the following SharePoint KB article, while not
directly related to SQL Server and SharePoint Portal Server, *might* be
helpful to you...
837367 How to turn on full-text search (FTS) in WSS (SharePoint) on a
Windows SBS 2003-based computer
http://support.microsoft.com/?kbid=837367
823377 (WSS) The database this server is using does not support search When
You Configure Full-Text Search for the Virtual Server
http://support.microsoft.com/default.aspx?kbid=823377
Also, if you have the Windows SharePoint Services 2.0 Administrator's Guide
help (a .chm file), you should also checkout title "Migrating from WMSDE to
SQL Server".
Regards,
John
"RDavid" <r@.c-m.NOSPAMcomm> wrote in message
news:#JjQiBvjEHA.3536@.TK2MSFTNGP12.phx.gbl...
> Hi John,
> I've about had it with this whole mess. I think I'm gonna issue 3x5 index
> cards for everyone to just write down information and to heck with SQL
> Server.
> Okay. The server I've been trying to get FTS running on is about 12 feet
> behind me. So I rolled my chair back there and logged off as Administrator
> and logged in as myself. When I called Query Analyzer up, it asked for the
> connection, so I gave it SVR1/SHAREPOINT and suddenly it just showed me
what
> it wouldn't show me before. <Grrrrrr>
> I ran the EXEC and the response was Data=LocalSystem
> So now that I found that out I went to the KB you indicated and read it,
and
> read it and read it and read it. It makes me think that I might just need
a
> 16 pound sledge hammer instead of only an 8 pound sledge. I guess the
> options of dealing with a stored procedure to perform the indexing
> (database, table, column, etc) is a matter of review and considerations
and
> trade offs as far as speed and needs. I need to find the tech-writer for
> WSS and have him/her reread the step by step instructions they show to
make[vbcol=seagreen]
> FTS work. It isn't any little trivial thing and yet the documentation is
> just, 'set this flag and save and voila!' Right, not hardly.
> So I need to find out which table/column needs to be searchable and then
> plan out which sp_ to use.
> Your help has been enormous and I'm very appreciative. I still feel dumb,
> but maybe some of this will finally sink in.
> Thank you,
> Rich
>
> "John Kane" <jt-kane@.comcast.net> wrote in message
> news:%23ACDr5tjEHA.3896@.TK2MSFTNGP15.phx.gbl...
should[vbcol=seagreen]
> be
your[vbcol=seagreen]
is[vbcol=seagreen]
> was
(local)[vbcol=seagreen]
EXEC...[vbcol=seagreen]
> will
'Administrator'[vbcol=seagreen]
> Not
> create
Server[vbcol=seagreen]
> DOMAIN\Account
would[vbcol=seagreen]
up[vbcol=seagreen]
> (CMSouth
> Analyzer
> not
well[vbcol=seagreen]
for[vbcol=seagreen]
> start
> on
and[vbcol=seagreen]
> BOL
not[vbcol=seagreen]
way[vbcol=seagreen]
the[vbcol=seagreen]
and[vbcol=seagreen]
your[vbcol=seagreen]
> below)
> behavior
issues
>
http://support.microsoft.com/default...per.asp#enable[vbcol=seagreen]
just[vbcol=seagreen]
(SVR1[vbcol=seagreen]
> time?
that[vbcol=seagreen]
> or
> Sharepoint
on[vbcol=seagreen]
how[vbcol=seagreen]
> root
> installed
the
>
|||John, you have the patience of Jobe.
And the saga continues...
In SQL Mgr a right click on the servers shows:
SVR1\SHAREPOINT
Server: SVR1\SHAREPOINT (combo box is disabled and ellipse is also
disabled)
Connection: Use Windows authentication is checked (Use SQL Server Auth
is NOT checked)
Options: Server Group = SQL Server Group (combo box only shows the one
group)
Display SQL Server in console = Checked
Show system db and objects = Checked
Auto start when connecting = Checked
(LOCAL)
Server: (LOCAL) (combo box is disabled and ellipse is also disabled)
Connection: Use Windows authentication is checked (Use SQL Server Auth
is NOT checked)
Options: Server Group = SQL Server Group (combo box only shows the one
group)
Display SQL Server in console = Checked
Show system db and objects = Checked
Auto start when connecting = Checked
When I click on the Add new registration for server the server I'm working
on (SVR1) is not listed. So the group only has (LOCAL) and SVR1\SHAREPOINT
but not SVR1 by itself.
You asked...
> Are you using the machine name or it's IP address or an alias for the
server?
I think the info above shows this (I think) but, the server name is SVR1 and
the domain name is CPM-South.
Also, I began to read the KB's you noted (thank you) and it seems that in
either case I've got to install SP3A. Well after viewing the webcast (some
of it anyway) on SP3A I'm not so sure that I want to get into that. I mean
there's a whole ton of new and different things any one of which could start
a nuclear meltdown on my SBS2003 server. If I don't do SP3A am I just
simply destined to have this orphan database (SVR1\SHAREPOINT), never to be
usable in either FTS or via Visual Studio? I hate to say this but my
options don't appear all that good.
All your info seems pretty good and I thank you for your help.
Rich
"John Kane" <jt-kane@.comcast.net> wrote in message
news:%235l1KGxjEHA.3624@.TK2MSFTNGP10.phx.gbl...
> You're welcome, Rich,
> Yea, I hear you and understand your frustration as I once told an ex-SQL
PM,
> that troubleshooting FTS is like trying to figure out what's on the other
> side of a black hole - as in nothing escapes a black hole, not even
light -
> so it's very difficult to see what's on the other side of a black hole!
> Anyways, the fact that the EXEC returned LocalSystem is a good thing...
Now,
> what I need to understand is how you have the remote server "registered"
in
> your SQL Server Enterprise Manager. Are you using the machine name or it's
> IP address or an alias for the server?
> While KB articles are sometimes not easy to understand (even for me and I
> wrote a few of them! ;), the following SharePoint KB article, while not
> directly related to SQL Server and SharePoint Portal Server, *might* be
> helpful to you...
> 837367 How to turn on full-text search (FTS) in WSS (SharePoint) on a
> Windows SBS 2003-based computer
> http://support.microsoft.com/?kbid=837367
> 823377 (WSS) The database this server is using does not support search
When
> You Configure Full-Text Search for the Virtual Server
> http://support.microsoft.com/default.aspx?kbid=823377
> Also, if you have the Windows SharePoint Services 2.0 Administrator's
Guide
> help (a .chm file), you should also checkout title "Migrating from WMSDE
to[vbcol=seagreen]
> SQL Server".
> Regards,
> John
>
> "RDavid" <r@.c-m.NOSPAMcomm> wrote in message
> news:#JjQiBvjEHA.3536@.TK2MSFTNGP12.phx.gbl...
index[vbcol=seagreen]
Administrator[vbcol=seagreen]
the[vbcol=seagreen]
> what
> and
need[vbcol=seagreen]
> a
> and
for[vbcol=seagreen]
> make
dumb,[vbcol=seagreen]
> should
> your
direct[vbcol=seagreen]
server?[vbcol=seagreen]
> is
and[vbcol=seagreen]
I[vbcol=seagreen]
> (local)
> EXEC...
it[vbcol=seagreen]
> 'Administrator'
up.[vbcol=seagreen]
(read[vbcol=seagreen]
the[vbcol=seagreen]
instance[vbcol=seagreen]
this[vbcol=seagreen]
so,[vbcol=seagreen]
Are[vbcol=seagreen]
You[vbcol=seagreen]
> Server
the[vbcol=seagreen]
the[vbcol=seagreen]
> would
> up
and[vbcol=seagreen]
> well
<G>[vbcol=seagreen]
various[vbcol=seagreen]
> for
search[vbcol=seagreen]
under[vbcol=seagreen]
> and
the[vbcol=seagreen]
> not
> way
> the
> and
> your
either
> issues
>
http://support.microsoft.com/default...per.asp#enable[vbcol=seagreen]
> just
> (SVR1
for[vbcol=seagreen]
server's[vbcol=seagreen]
> that
it[vbcol=seagreen]
something[vbcol=seagreen]
working[vbcol=seagreen]
2002[vbcol=seagreen]
Edition[vbcol=seagreen]
> on
> how
NT)
> the
>

Basics, just the basics please

Hello you geniuses,
I've read so many articles in here about full-text searching that it's all
beginning to slip out of my ears.
Most everyone seems to have gotten something working but then it ends up
with problems or issues when configurations change or something externally
effects it. As for me, I don't know if I have something working or not and
would just like to get the FTS working as part of Windows Sharepoint
Services (WSS).
SELECT @.@.version:
Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Dec 17 2002 14:22:05
Copyright (c) 1988-2003 Microsoft Corporation Standard Edition on Windows
NT 5.2 (Build 3790: )
SELECT @.@.language:
us_english
OS: SBS2003 DC
Is there someplace that has a "SQL Full-Text Search Setup for Dummy's?" like
paper, so I can follow by the numbers rather than ponder just how much is
done and not done or jump in and out without understanding the root of how
FTS works? And does the FTS get set for ALL of SQL that's installed or just
per SQL Server Group? I have two groups; (LOCAL) (Windows NT) and
(SVR1 SHAREPOINT) (Windows NT), would they both be handled at the same time?
Any help would be appreciated by this addled brained IT guy,
Rich
Rich,
Well, thank you! I've not been called a "genius" in sometime! <G>
Unfortunately, books on this subject have been delayed for various reasons
(I'm writing one), so for now there is no "SQL Full-Text Search for Dummy's"
(yet), but look for one soon! In the meantime, the best place to start is
SQL Server 2000 Books online (BOL) using the search tab and search on "full
text search" using the double quotes. The basics are covered under titles
"Full-Text Query Architecture", "Full-Text Catalogs and Indexes" and
"Full-text Querying SQL Server Data". Also, you should review the BOL for
CONTAINS, CONTAINSTABLE, FREETEXT and FREETEXTTABLE and last but not least
"Full-Text Search Recommendations". Mostly, the best and easiest way to
FT-enable the database as well as table and columns is to launch the
Full-Text Indexing Wizard (sqlftwiz.exe) from the SQL Enterprise Manager and
it will prompt you through all the steps necessary to FT-enable and schedule
a Full Population for you or you can run a Full Population at your own
convience.
Yes, there are problems with SQL FTS, but mainly these are either FAQ's that
currently are not documented in KB articles (see a list of KB's below) or
are bugs or differences due to OS platforms, i.e., difference behavior and
results between Win2K and Win2003. Additionally, many SQL FTS issues are
related to either performance or scalability issues and lack of
customization. FYI, many of these bugs are being addressed by Microsoft in
the next release of SQL Server 2005 (codename Yukon).
You should also review the FTS Deployment whitepaper (I was a *contributor*)
and how to enable at:
http://support.microsoft.com/default...per.asp#enable
Q. And does the FTS get set for ALL of SQL that's installed or just per SQL
Server Group? I have two groups; (LOCAL) (Windows NT) and (SVR1
SHAREPOINT) (Windows NT), would they both be handled at the same time?
A. Yes and no... Specifically, FTS is installed and functional for both your
local and SVR1 SHAREPOINT (named instance), however, each server's database
must be FT-enabled separately via the FT Indexing Wizard.
Hope that helps!
John
"RDavid" <r@.c-m.NOSPAMcomm> wrote in message
news:eRVef2JhEHA.3272@.TK2MSFTNGP11.phx.gbl...
> Hello you geniuses,
> I've read so many articles in here about full-text searching that it's all
> beginning to slip out of my ears.
> Most everyone seems to have gotten something working but then it ends up
> with problems or issues when configurations change or something externally
> effects it. As for me, I don't know if I have something working or not
and
> would just like to get the FTS working as part of Windows Sharepoint
> Services (WSS).
> SELECT @.@.version:
> Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Dec 17 2002 14:22:05
> Copyright (c) 1988-2003 Microsoft Corporation Standard Edition on Windows
> NT 5.2 (Build 3790: )
> SELECT @.@.language:
> us_english
> OS: SBS2003 DC
> Is there someplace that has a "SQL Full-Text Search Setup for Dummy's?"
like
> paper, so I can follow by the numbers rather than ponder just how much is
> done and not done or jump in and out without understanding the root of how
> FTS works? And does the FTS get set for ALL of SQL that's installed or
just
> per SQL Server Group? I have two groups; (LOCAL) (Windows NT) and
> (SVR1 SHAREPOINT) (Windows NT), would they both be handled at the same
time?
> Any help would be appreciated by this addled brained IT guy,
> Rich
>
|||John,
Thanks for your reply. I've got some reading to do, thanks for the lead.
On the other issue I raised, regarding whether or not two groups would be
handled as one, you indicated that both would need to have FTS set up
through the wizard for FTS to take effect.
The two groups I have are like this:
Microsoft SQL Servers
SQL Server Group
(LOCAL) (Windows NT)
(SVR1\SHAREPOINT) (Windows NT)
When I highlight the LOCAL one, I get (under Tools) Full-Text Indexing... as
an enabled choice. But when I highlight the SHAREPOINT one, the Full-Text
Indexing... is greyed out.
I checked under Security on both and then Logins and both have
BUILTIN\Administrators (group) and CMSouth\Administrator (user) (CMSouth is
the domain name of SVR1). Along with an 'sa' for both.
Is there something I'm missing here? When I go into the Query Analyzer and
it prompts for the server to connect to, it only offers "local" and not the
SHAREPOINT database group.
I would appreciate any light you might shed on this.
Rich
PS: And yes, I did say genius. Anyone who can understand this as well as
you deserves that label.
"John Kane" <jt-kane@.comcast.net> wrote in message
news:unU3fPMhEHA.3664@.TK2MSFTNGP11.phx.gbl...
> Rich,
> Well, thank you! I've not been called a "genius" in sometime! <G>
> Unfortunately, books on this subject have been delayed for various reasons
> (I'm writing one), so for now there is no "SQL Full-Text Search for
Dummy's"
> (yet), but look for one soon! In the meantime, the best place to start is
> SQL Server 2000 Books online (BOL) using the search tab and search on
"full
> text search" using the double quotes. The basics are covered under titles
> "Full-Text Query Architecture", "Full-Text Catalogs and Indexes" and
> "Full-text Querying SQL Server Data". Also, you should review the BOL for
> CONTAINS, CONTAINSTABLE, FREETEXT and FREETEXTTABLE and last but not least
> "Full-Text Search Recommendations". Mostly, the best and easiest way to
> FT-enable the database as well as table and columns is to launch the
> Full-Text Indexing Wizard (sqlftwiz.exe) from the SQL Enterprise Manager
and
> it will prompt you through all the steps necessary to FT-enable and
schedule
> a Full Population for you or you can run a Full Population at your own
> convience.
> Yes, there are problems with SQL FTS, but mainly these are either FAQ's
that
> currently are not documented in KB articles (see a list of KB's below) or
> are bugs or differences due to OS platforms, i.e., difference behavior and
> results between Win2K and Win2003. Additionally, many SQL FTS issues are
> related to either performance or scalability issues and lack of
> customization. FYI, many of these bugs are being addressed by Microsoft in
> the next release of SQL Server 2005 (codename Yukon).
> You should also review the FTS Deployment whitepaper (I was a
*contributor*)
> and how to enable at:
>
http://support.microsoft.com/default...per.asp#enable
>
> Q. And does the FTS get set for ALL of SQL that's installed or just per
SQL
> Server Group? I have two groups; (LOCAL) (Windows NT) and (SVR1
> SHAREPOINT) (Windows NT), would they both be handled at the same time?
> A. Yes and no... Specifically, FTS is installed and functional for both
your
> local and SVR1 SHAREPOINT (named instance), however, each server's
database[vbcol=seagreen]
> must be FT-enabled separately via the FT Indexing Wizard.
> Hope that helps!
> John
>
>
> "RDavid" <r@.c-m.NOSPAMcomm> wrote in message
> news:eRVef2JhEHA.3272@.TK2MSFTNGP11.phx.gbl...
all[vbcol=seagreen]
externally[vbcol=seagreen]
> and
Windows[vbcol=seagreen]
> like
is[vbcol=seagreen]
how
> just
> time?
>
|||You're welcome, Rich !
Under your SHAREPOINT named instance of SQL Server, could you run the
following code and post the result?
EXEC master..xp_regread 'HKEY_LOCAL_MACHINE',
'SYSTEM\CurrentControlSet\Services\MSSQL$SHAREPOIN T', 'ObjectName'
go
The output Data should be the exact account that this named instance
(SHAREPOINT) is running under. If it is a local Windows account, this could
explain why the Full-Text Indexing menu items are grayed out. If so, please
review KB article Q270671 (Q270671) "PRB: Full Text Search Menus Are Not
Enabled for Local Windows NT Accounts" at:
http://support.microsoft.com/default...;en-us;q270671 You should
test using the system stored procs sp_fulltext_* to see if you can create a
FT Catalog and run a Full Population. If you can change the SQL Server named
instance (SHAREPOINT) startup account to a new or existing DOMAIN\Account
that is a member of the server's Admin. Group, and not the DOMAIN
Administrator account (I'm assuming that CMSouth\Administrator is the Domain
Admin account) that could solve this issue too.
Thanks,
John "Genius" Kane ;-))
"RDavid" <r@.c-m.NOSPAMcomm> wrote in message
news:#9vvgTVhEHA.2908@.TK2MSFTNGP10.phx.gbl...
> John,
> Thanks for your reply. I've got some reading to do, thanks for the lead.
> On the other issue I raised, regarding whether or not two groups would be
> handled as one, you indicated that both would need to have FTS set up
> through the wizard for FTS to take effect.
> The two groups I have are like this:
> Microsoft SQL Servers
> SQL Server Group
> (LOCAL) (Windows NT)
> (SVR1\SHAREPOINT) (Windows NT)
> When I highlight the LOCAL one, I get (under Tools) Full-Text Indexing...
as
> an enabled choice. But when I highlight the SHAREPOINT one, the Full-Text
> Indexing... is greyed out.
> I checked under Security on both and then Logins and both have
> BUILTIN\Administrators (group) and CMSouth\Administrator (user) (CMSouth
is
> the domain name of SVR1). Along with an 'sa' for both.
> Is there something I'm missing here? When I go into the Query Analyzer
and
> it prompts for the server to connect to, it only offers "local" and not
the[vbcol=seagreen]
> SHAREPOINT database group.
> I would appreciate any light you might shed on this.
> Rich
> PS: And yes, I did say genius. Anyone who can understand this as well as
> you deserves that label.
>
>
>
> "John Kane" <jt-kane@.comcast.net> wrote in message
> news:unU3fPMhEHA.3664@.TK2MSFTNGP11.phx.gbl...
reasons[vbcol=seagreen]
> Dummy's"
is[vbcol=seagreen]
> "full
titles[vbcol=seagreen]
for[vbcol=seagreen]
least[vbcol=seagreen]
> and
> schedule
> that
or[vbcol=seagreen]
and[vbcol=seagreen]
in
> *contributor*)
>
http://support.microsoft.com/default...per.asp#enable[vbcol=seagreen]
> SQL
> your
> database
> all
up[vbcol=seagreen]
> externally
not[vbcol=seagreen]
14:22:05[vbcol=seagreen]
> Windows
Dummy's?"[vbcol=seagreen]
> is
> how
or
>

2012年2月9日星期四

Basic Questions about SQL Server IO Optimization

Hi,
I am a programmer and my understanding of low-level database I/O
issues is limited. I've just taken a job with a company that is
currently using classic asp with inline sql. I come from an
environment with stored procs and I'm used to dealing in full records
and recordsets. We've been discussing database IO and my colleagues
here feel that it's necessary with classic asp to only pull in fields
you need, even if you're working with one record in a table. This,
they feel, will will cut down on IO time and bandwidth.
In my reading, I've gotten the impression that the days of worrying
about how many fields you bring in from one record are in the past
since I/O involves paging (meaning that more than a couple of fields
are brought in no matter what) and disks are so fast it doesn't
matter.
To support their arguments they've brought up the issue of bringing
in ntext fields which can slow down an I/0 operation. In this case I
agree with them but there methodology goes against the whole idea of
standard I/O concepts (e.g. creating stored procs to read and write to
at least an entire record).
I'm not certain of my take on things. I hope that someone might give
me some guidance and perhaps some articles to read on this subject.
What we have here is a lot of disparate in-line sql which I feel is
redudant and not easily modified since it's all over the place (i.e.
the addtion of one critical field in a table would require changing
hundreds of isolated inline sql strings).
Any advice would be appreciated.
Thanks,
Fig
"fig000" <neilnewton001@.yahoo.com> wrote in message
news:1176731759.224287.121120@.y5g2000hsa.googlegro ups.com...
> Hi,
> I am a programmer and my understanding of low-level database I/O
> issues is limited. I've just taken a job with a company that is
> currently using classic asp with inline sql. I come from an
> environment with stored procs and I'm used to dealing in full records
> and recordsets. We've been discussing database IO and my colleagues
> here feel that it's necessary with classic asp to only pull in fields
> you need, even if you're working with one record in a table. This,
> they feel, will will cut down on IO time and bandwidth.
Generally they're probably correct. If you're suggesting a select * is "ok"
your own example below seems to agree with the problems that might cause.
Also, consider a case where their select statement only brings back 2 fields
from a row, but those 2 fields are in a covering index. In that case, the
IO can be VERY effecient.
If they were bring back additional rows not in the covered index and not
using them, the IO usage can go way up.
Overall though I'd agree, getting rid of inline stuff and replacing with
stored procedures would probably be even better. :-)

> In my reading, I've gotten the impression that the days of worrying
> about how many fields you bring in from one record are in the past
> since I/O involves paging (meaning that more than a couple of fields
> are brought in no matter what) and disks are so fast it doesn't
> matter.
> To support their arguments they've brought up the issue of bringing
> in ntext fields which can slow down an I/0 operation. In this case I
> agree with them but there methodology goes against the whole idea of
> standard I/O concepts (e.g. creating stored procs to read and write to
> at least an entire record).
> I'm not certain of my take on things. I hope that someone might give
> me some guidance and perhaps some articles to read on this subject.
> What we have here is a lot of disparate in-line sql which I feel is
> redudant and not easily modified since it's all over the place (i.e.
> the addtion of one critical field in a table would require changing
> hundreds of isolated inline sql strings).
> Any advice would be appreciated.
> Thanks,
> Fig
>
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html
|||Greg,
Thanks for answering. I can see that there is no simple answer to
this question. What I wonder then, is how the whole current trend got
started: creating a stored procedure for each of the four crud
operations for each table in a database. This is sort of underscored
by the development of all the wizards (datadapter in 2003 and
tableadapter in 2005). Are these simply bad practices which simplify
programming?
I guess I can see these issues if you are reading a large number of
records (which would make the use of the ado.net recordsets dangerious
if not used carefully). But for one record (or a few) wouldn't the
difference between reading two fields or 50 be minimal in terms of
database I/O? If I'm right, wouldn't the use of a standardized "select
*" type of functionality be more convenient from a coding standpoint
and cause little trouble in terms of database I/O?
I guess my final question would be: how could possibly put hundreds
of disparate queries selecting various sets of fields from a table or
tables, into stored procs? Wouldn't the complexity of that be an
argument for standardizing the SQL for a table into four simple crud
queries that could be called from any part of the system. Wouldn't
that also make modifying the queries (say for adding a new crictical
field) much easier.
I admit I don't know much about database internals so please forgive
my possible ignorance.
Thanks again for answering this sort of off the wall request. Are
there any articles or books that might clear this up for me?
Fig
On Apr 16, 10:58 am, "Greg D. Moore \(Strider\)"
<mooregr_deletet...@.greenms.com> wrote:
> "fig000" <neilnewton...@.yahoo.com> wrote in message
> news:1176731759.224287.121120@.y5g2000hsa.googlegro ups.com...
>
> Generally they're probably correct. If you're suggesting a select * is "ok"
> your own example below seems to agree with the problems that might cause.
> Also, consider a case where their select statement only brings back 2 fields
> from a row, but those 2 fields are in a covering index. In that case, the
> IO can be VERY effecient.
> If they were bring back additional rows not in the covered index and not
> using them, the IO usage can go way up.
> Overall though I'd agree, getting rid of inline stuff and replacing with
> stored procedures would probably be even better. :-)
>
>
>
>
>
> --
> Greg Moore
> SQL Server DBA Consulting Remote and Onsite available!
> Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html
|||Fig,
SQL Server uses a cost based optimizer that is getting smarter with each
release. The more to-the-point your query gets, the more options the
optimizer has to achieve this as fast and efficient as possible. If you
don't need all columns of a row, then don't ask for it.
There are many examples where the optimizer can speed things up if you
ask less, so the ones below are just some examples.
- If there is a covering index (an index that holds all the columns
needed for your query) that it can be used instead of the base table. A
covering index is typically much smaller than the table, so on average
less I/O is required to retrieve the same number of rows
- If a row's size expands to over 4096 bytes, for example because you
just update a varchar column with a bigger string, then the data of this
column will be moved to a separate page. If you do not use this column
in your select query, this extra page does not have to be retrieved
- If you have text, ntext or image column in your table. Their values
are typically (but not always) stored in seperate pages
- If there is an indexed view defined for the table, it might be used
instead of the actual table (provided you are using Enterprise Edition)
One last thing. You are right, that if the storage engine has to
retrieve a page of table data, then (apart from the cases above) most or
all row data is retrieved. However, if the query plan has multiple
operators, all columns that are selected have to be kept in memory and
(possible) processed. This might involve I/O in tempdb. Also, the data
has to be piped to your application. Over a WAN that might cause
(serious) delays.
HTH,
Gert-Jan
fig000 wrote:
> Hi,
> I am a programmer and my understanding of low-level database I/O
> issues is limited. I've just taken a job with a company that is
> currently using classic asp with inline sql. I come from an
> environment with stored procs and I'm used to dealing in full records
> and recordsets. We've been discussing database IO and my colleagues
> here feel that it's necessary with classic asp to only pull in fields
> you need, even if you're working with one record in a table. This,
> they feel, will will cut down on IO time and bandwidth.
> In my reading, I've gotten the impression that the days of worrying
> about how many fields you bring in from one record are in the past
> since I/O involves paging (meaning that more than a couple of fields
> are brought in no matter what) and disks are so fast it doesn't
> matter.
> To support their arguments they've brought up the issue of bringing
> in ntext fields which can slow down an I/0 operation. In this case I
> agree with them but there methodology goes against the whole idea of
> standard I/O concepts (e.g. creating stored procs to read and write to
> at least an entire record).
> I'm not certain of my take on things. I hope that someone might give
> me some guidance and perhaps some articles to read on this subject.
> What we have here is a lot of disparate in-line sql which I feel is
> redudant and not easily modified since it's all over the place (i.e.
> the addtion of one critical field in a table would require changing
> hundreds of isolated inline sql strings).
> Any advice would be appreciated.
> Thanks,
> Fig
|||Best practice for me is usually what you said, and what they said.
Return only what you need, and use stored procedures.
On Apr 16, 3:51 pm, "fig000" <neilnewton...@.yahoo.com> wrote:
> Greg,
> Thanks for answering. I can see that there is no simple answer to
> this question. What I wonder then, is how the whole current trend got
> started: creating a stored procedure for each of the four crud
> operations for each table in a database. This is sort of underscored
> by the development of all the wizards (datadapter in 2003 and
> tableadapter in 2005). Are these simply bad practices which simplify
> programming?
> I guess I can see these issues if you are reading a large number of
> records (which would make the use of the ado.net recordsets dangerious
> if not used carefully). But for one record (or a few) wouldn't the
> difference between reading two fields or 50 be minimal in terms of
> database I/O? If I'm right, wouldn't the use of a standardized "select
> *" type of functionality be more convenient from a coding standpoint
> and cause little trouble in terms of database I/O?
> I guess my final question would be: how could possibly put hundreds
> of disparate queries selecting various sets of fields from a table or
> tables, into stored procs? Wouldn't the complexity of that be an
> argument for standardizing the SQL for a table into four simple crud
> queries that could be called from any part of the system. Wouldn't
> that also make modifying the queries (say for adding a new crictical
> field) much easier.
> I admit I don't know much about database internals so please forgive
> my possible ignorance.
> Thanks again for answering this sort of off the wall request. Are
> there any articles or books that might clear this up for me?
> Fig
> On Apr 16, 10:58 am, "Greg D. Moore \(Strider\)"
>
> <mooregr_deletet...@.greenms.com> wrote:
>
>
>
>
>
>
>
> - Show quoted text -
|||"fig000" <neilnewton001@.yahoo.com> wrote in message
news:1176753103.971027.241230@.y80g2000hsf.googlegr oups.com...
> Greg,
> Thanks for answering. I can see that there is no simple answer to
> this question. What I wonder then, is how the whole current trend got
> started: creating a stored procedure for each of the four crud
> operations for each table in a database. This is sort of underscored
> by the development of all the wizards (datadapter in 2003 and
> tableadapter in 2005). Are these simply bad practices which simplify
> programming?
Not really sure what you're asking here.

> I guess I can see these issues if you are reading a large number of
> records (which would make the use of the ado.net recordsets dangerious
> if not used carefully). But for one record (or a few) wouldn't the
> difference between reading two fields or 50 be minimal in terms of
> database I/O?
Not necessarily. Let's say you want to read one record.
In that case, (I'm going to assume basic, row, no large blobs), you need to
read one 8K page.
Fair enough. Even if you only need two fields (say a total of 100 bytes)
you're reading an 8K page.
However, consider the situation where each call only returns 1 row, but you
call that code 100 times.
Worse case scenario, you need to read 100 8K pages. (This assumes a select
* from...)
Best case with say a covering index and returning 100 bytes is reading in 2
8K pages.
That's 50 times more effecient.
Now, in the worst case, if the pages are scattered all over the disk, you
might need a physical read for each one. That's 100 physical reads.
In the best case, you need two physical reads and in some cases just ONE
physical read (since the engine will generally read multiple pages in a row
in one pass). Combine that with lack of arm movement and this suddenly
becomes far more effecient.

> If I'm right, wouldn't the use of a standardized "select
> *" type of functionality be more convenient from a coding standpoint
> and cause little trouble in terms of database I/O?
Well if you want a worse case of 100x slower I/O sure that's a little
trouble. :-)
(and note we're assuming you don't have any large blobs returned in a select
* that are thrown away.)
And actually a select * could be far worse than the 100 reads above in some
cases, depending on choices the optimizer will make.

> I guess my final question would be: how could possibly put hundreds
> of disparate queries selecting various sets of fields from a table or
> tables, into stored procs? Wouldn't the complexity of that be an
> argument for standardizing the SQL for a table into four simple crud
> queries that could be called from any part of the system. Wouldn't
> that also make modifying the queries (say for adding a new crictical
> field) much easier.
Well from the above, sounds more like the whole application might need to be
reviewed.
You can get other benefits from stored procs also, query/plan re-use,
protect against SQL injection attacks.

> I admit I don't know much about database internals so please forgive
> my possible ignorance.
> Thanks again for answering this sort of off the wall request. Are
> there any articles or books that might clear this up for me?
Yeah.. Inside SQL Server either for 2000 or 2005 depending on what you're
using.

> Fig
> On Apr 16, 10:58 am, "Greg D. Moore \(Strider\)"
> <mooregr_deletet...@.greenms.com> wrote:
>
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html