Showing posts with label file. Show all posts
Showing posts with label file. Show all posts

Thursday, March 29, 2012

Credentials and extended stored procedures

I have a database script that uses the extended stored procedures sp_OACreate and sp_OCMethod to execute an .exe file. The .exe file is located on the same machine as the SQL Server. At this time it does nothing but log the name of the user calling it.

When I execute the script from Management Studio (logged in as myself) the user being logged as the caller of the .exe is still NT AUTHORITY\SYSTEM. I don't know why NT AUTHORITY\SYSTEM is the caller, cause the SQL Server service runs under another domain account.

I have tried playing around with EXECUTE AS USER but no matter what, the caller of the .exe is always logged as NT AUTHORITY\SYSTEM.

Are there any way I can pass my credentials to the executable that I am calling from the T-SQL script?

Have you given the NT AUTHORITY/SYSTEM privileges on SQL Server?|||

No, not intentionally. It is a default SQL server installation.

I switched the user that runs the SQL service to a domain user (it was local system account before), and that is basically all that has been changed, apart from giving some domain users access to some databases on the server.

Tuesday, March 27, 2012

Creating xsd schema file for a xml file ...

Hi ...
I need to bulk insert the xml data below. I am working on some issues related to the Itentity column (you may have read the other question).
The xml below uses elements with attributes. Is the schema file formated correctly to extract the attributes from the SITE element and then also extract the attributes from the ATMOSPHERIC element ... ? Not sure about the schema file ?
Thanks,
Chris

////////////////////////////////////////////////////
// schema file
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:element name="site" sql:relation="MacgowanTestRWISRawAtmospheric" >
<xsd:complexType>
<xsd:attribute name="sysid" type="xsd:string" sql:field="SystemId"/>
<xsd:attribute name="rpuid" type="xsd:string" sql:field="RpuId"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="atmospheric" sql:relation="MacgowanTestRWISRawAtmospheric" >
<xsd:complexType>
<xsd:attribute name="datetime" type="xsd:date" sql:field="ObsDateTime"/>
<xsd:attribute name="airtemp" type="xsd:string" sql:field="Temperature"/>
<xsd:attribute name="dewpoint" type="xsd:string" sql:field="DewPoint"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>

////////////////////////////////////////////////////
// xml data
<?xml version="1.0"?>
<odot_rwis_site_info>
<site id="200000" number="1" sysid="200" rpuid="0" name="1-SR127 @. SR249" longitude="-84.554946" latitude="41.383527">
<atmospheric datetime="12/05/2005 03:48:00 PM" airtemp="-490" dewpoint="-800" relativehumidity="73" windspeedavg="11" windspeedgust="19" winddirectionavg="265" winddirectiongust="295" pressure="65535" precipitationintensity="None" precipitationtype="None" precipitationrate="0" precipitationaccumulation="-1" visibility="2000" />
<sensors>
<surface id="0" datetime="12/05/2005 03:48:00 PM" name="North Bound Driving Lane" surfacecondition="Dry" surfacetemp="1900" freezingtemp="32767" chemicalfactor="255" chemicalpercent="255" depth="32767" icepercent="255" subsurfacetemp="450" waterlevel="0">
<traffic datetime="12/05/2005 03:48:00 PM" occupancy="0" avgspeed="82" volume="21" sftemp="1900" sfstate="255">
<normalbins>
<bin datetime="12/05/2005 03:48:00 PM" binnumber="0" bincount="7" />
<bin datetime="12/05/2005 03:48:00 PM" binnumber="1" bincount="0" />
</normalbins>
<longbins>
<bin datetime="12/05/2005 03:48:00 PM" binnumber="2" bincount="0" />
<bin datetime="12/05/2005 03:48:00 PM" binnumber="3" bincount="0" />
<bin datetime="12/05/2005 03:48:00 PM" binnumber="4" bincount="1" />
<bin datetime="12/05/2005 03:48:00 PM" binnumber="5" bincount="0" />
</longbins>
</traffic>
</surface>
<surface id="1" datetime="12/05/2005 03:48:00 PM" name="Bridge Deck Simulator" surfacecondition="Other" surfacetemp="-60" freezingtemp="32767" chemicalfactor="255" chemicalpercent="255" depth="32767" icepercent="255" subsurfacetemp="-999999" waterlevel="0" />
</sensors>
</site>
</odot_rwis_site_info>

////////////////////////////////////////////////////
// table
CREATE TABLE [MacgowanTestRWISRawAtmospheric] (
[RecordId] [int] IDENTITY (1, 1) NOT NULL ,
[DataSourceId] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_MacgowanTestRWISRawAtmospheric_DataSourceId] DEFAULT ('OH'),
[ProductInstanceId] [char] (38) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_MacgowanTestRWISRawAtmospheric_ProductInstanceId] DEFAULT ('5abbbc86-fb2c-4703-9589-b55f763ee150'),
[SystemId] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[RpuId] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[SensorId] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[ObsDateTime] [datetime] NULL ,
[InsertDateTime] [datetime] NOT NULL CONSTRAINT [DF_MacgowanTestRWISRawAtmospheric_InsertDateTime] DEFAULT (getdate()),
[Temperature] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[DewPoint] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[RelativeHumidity] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WSPD] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WSPDGust] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WDIRMin] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WDIRAvg] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WDIRMax] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipIntensity] [char] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipType] [char] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipRate] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Pressure] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Visability] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[AirTempMax] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[AirTempMin] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WetBulbTemp] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[LastPrecipStart] [datetime] NULL ,
[LastPrecipEnd] [datetime] NULL ,
[PrecipAccum1Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum3Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum6Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum12Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum24Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
CONSTRAINT [PK_MacgowanTestRWISRawAtmospheric] PRIMARY KEY NONCLUSTERED
(
[RecordId]
) WITH FILLFACTOR = 70 ON [PRIMARY]
) ON [PRIMARY]
GO

Not sure if I understand the question fully. Are you having any specific issues with bulk loading this data? or the issue is validating your XML data against XSD?

thanks

|||Hi ...

Sorry about the confusion. I was having some issues with bulk

loading using the IDENTITY Column in the target table. I was

setting the COM attribute KeepIdentity to TRUE rather than FALSE.

The schema and xml are correct.

Thanks,

Chris

Creating xsd schema file for a xml file ...

Hi ...
I need to bulk insert the xml data below. I am working on some issues related to the Itentity column (you may have read the other question).
The xml below uses elements with attributes. Is the schema file formated correctly to extract the attributes from the SITE element and then also extract the attributes from the ATMOSPHERIC element ... ? Not sure about the schema file ?
Thanks,
Chris

////////////////////////////////////////////////////
// schema file
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:element name="site" sql:relation="MacgowanTestRWISRawAtmospheric" >
<xsd:complexType>
<xsd:attribute name="sysid" type="xsd:string" sql:field="SystemId"/>
<xsd:attribute name="rpuid" type="xsd:string" sql:field="RpuId"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="atmospheric" sql:relation="MacgowanTestRWISRawAtmospheric" >
<xsd:complexType>
<xsd:attribute name="datetime" type="xsd:date" sql:field="ObsDateTime"/>
<xsd:attribute name="airtemp" type="xsd:string" sql:field="Temperature"/>
<xsd:attribute name="dewpoint" type="xsd:string" sql:field="DewPoint"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>

////////////////////////////////////////////////////
// xml data
<?xml version="1.0"?>
<odot_rwis_site_info>
<site id="200000" number="1" sysid="200" rpuid="0" name="1-SR127 @. SR249" longitude="-84.554946" latitude="41.383527">
<atmospheric datetime="12/05/2005 03:48:00 PM" airtemp="-490" dewpoint="-800" relativehumidity="73" windspeedavg="11" windspeedgust="19" winddirectionavg="265" winddirectiongust="295" pressure="65535" precipitationintensity="None" precipitationtype="None" precipitationrate="0" precipitationaccumulation="-1" visibility="2000" />
<sensors>
<surface id="0" datetime="12/05/2005 03:48:00 PM" name="North Bound Driving Lane" surfacecondition="Dry" surfacetemp="1900" freezingtemp="32767" chemicalfactor="255" chemicalpercent="255" depth="32767" icepercent="255" subsurfacetemp="450" waterlevel="0">
<traffic datetime="12/05/2005 03:48:00 PM" occupancy="0" avgspeed="82" volume="21" sftemp="1900" sfstate="255">
<normalbins>
<bin datetime="12/05/2005 03:48:00 PM" binnumber="0" bincount="7" />
<bin datetime="12/05/2005 03:48:00 PM" binnumber="1" bincount="0" />
</normalbins>
<longbins>
<bin datetime="12/05/2005 03:48:00 PM" binnumber="2" bincount="0" />
<bin datetime="12/05/2005 03:48:00 PM" binnumber="3" bincount="0" />
<bin datetime="12/05/2005 03:48:00 PM" binnumber="4" bincount="1" />
<bin datetime="12/05/2005 03:48:00 PM" binnumber="5" bincount="0" />
</longbins>
</traffic>
</surface>
<surface id="1" datetime="12/05/2005 03:48:00 PM" name="Bridge Deck Simulator" surfacecondition="Other" surfacetemp="-60" freezingtemp="32767" chemicalfactor="255" chemicalpercent="255" depth="32767" icepercent="255" subsurfacetemp="-999999" waterlevel="0" />
</sensors>
</site>
</odot_rwis_site_info>

////////////////////////////////////////////////////
// table
CREATE TABLE [MacgowanTestRWISRawAtmospheric] (
[RecordId] [int] IDENTITY (1, 1) NOT NULL ,
[DataSourceId] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_MacgowanTestRWISRawAtmospheric_DataSourceId] DEFAULT ('OH'),
[ProductInstanceId] [char] (38) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_MacgowanTestRWISRawAtmospheric_ProductInstanceId] DEFAULT ('5abbbc86-fb2c-4703-9589-b55f763ee150'),
[SystemId] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[RpuId] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[SensorId] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[ObsDateTime] [datetime] NULL ,
[InsertDateTime] [datetime] NOT NULL CONSTRAINT [DF_MacgowanTestRWISRawAtmospheric_InsertDateTime] DEFAULT (getdate()),
[Temperature] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[DewPoint] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[RelativeHumidity] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WSPD] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WSPDGust] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WDIRMin] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WDIRAvg] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WDIRMax] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipIntensity] [char] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipType] [char] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipRate] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Pressure] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Visability] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[AirTempMax] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[AirTempMin] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WetBulbTemp] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[LastPrecipStart] [datetime] NULL ,
[LastPrecipEnd] [datetime] NULL ,
[PrecipAccum1Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum3Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum6Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum12Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PrecipAccum24Hour] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
CONSTRAINT [PK_MacgowanTestRWISRawAtmospheric] PRIMARY KEY NONCLUSTERED
(
[RecordId]
) WITH FILLFACTOR = 70 ON [PRIMARY]
) ON [PRIMARY]
GO

Not sure if I understand the question fully. Are you having any specific issues with bulk loading this data? or the issue is validating your XML data against XSD?

thanks

|||Hi ...
Sorry about the confusion. I was having some issues with bulk loading using the IDENTITY Column in the target table. I was setting the COM attribute KeepIdentity to TRUE rather than FALSE.
The schema and xml are correct.
Thanks,
Chris

Creating XML output...unusual/impossible format?

Hi all,

I'm Trying to replicate the creation of an "xml" file that is currently created using a C++ application. I want to take that application out of the picture, but need to create the same format XML file because a step later in the production process uses this file, and I cannot change it.

The output format I am looking for is:<?xml version="1.0" encoding="utf-8"?>
<FUNDS>
<AMRGX>
<NAME>AMERICAN GROWTH D</NAME>
</AMRGX>
<AHERX>
<NAME>AMERICAN HERITAGE FUND</NAME>
</AHERX>
<AMRVX>
<NAME>AMERICAN INVESTORS GROWTH FUND</NAME>
</AMRVX>
.
.
.
</FUNDS>The problem I am having is that I cannot seem to get the level/node of the fund symbol (AMRGX, AHERX, and AMRVX in the example above) as it needs to be. I think this must be some non-standard use of XML, since the tag is really the data itself (?)

The closest I have been able to get so far is:
<FUNDS>
<SYMBOL>AMRGX</SYMBOL>
<NAME>AMERICAN GROWTH D</NAME>
</FUNDS>
<FUNDS>
<SYMBOL>AHERX</SYMBOL>
<NAME>AMERICAN HERITAGE FUND</NAME>
</FUNDS>
.
.
.As you can see (hopefully) I am able to get the data I need but cannot get:
(1) the FUNDS tag(s) to be the very highest level/root.
nor (2) the SYMBOL part (tag label?) to be the actual variable stock fund.

Am I 'splaining this well enough? I don't necessarily need all the code, since I know I haven't given enough info to help with that, but my basic question is - - Is it possible to get a variable TAG based on the table DATA?

I want my SYMBOL tag to be the actual SYMBOL for the stock fund.

Confused? Not as much as I am *LOL* I am new to the use of all but XML EXPLICIT use, so any help would be appreciated - at least regarding my two formatting questions.

Yes, I have (and am still) searching around BOL for my answers, but so I have found nothing that helps me out. Meanwhile, suggestions are welcome!

Thanks!You cannot achieve this with a single SELECT statement because you can have only one column name for the entire result set.(you stated this already). If you need to have the column value as a tag then a stored procedure is the way to go where you can generate your own XML TAGs.
Hi all,

I'm Trying to replicate the creation of an "xml" file that is currently created using a C++ application. I want to take that application out of the picture, but need to create the same format XML file because a step later in the production process uses this file, and I cannot change it.

The output format I am looking for is:<?xml version="1.0" encoding="utf-8"?>
<FUNDS>
<AMRGX>
<NAME>AMERICAN GROWTH D</NAME>
</AMRGX>
<AHERX>
<NAME>AMERICAN HERITAGE FUND</NAME>
</AHERX>
<AMRVX>
<NAME>AMERICAN INVESTORS GROWTH FUND</NAME>
</AMRVX>
.
.
.
</FUNDS>The problem I am having is that I cannot seem to get the level/node of the fund symbol (AMRGX, AHERX, and AMRVX in the example above) as it needs to be. I think this must be some non-standard use of XML, since the tag is really the data itself (?)

The closest I have been able to get so far is:
<FUNDS>
<SYMBOL>AMRGX</SYMBOL>
<NAME>AMERICAN GROWTH D</NAME>
</FUNDS>
<FUNDS>
<SYMBOL>AHERX</SYMBOL>
<NAME>AMERICAN HERITAGE FUND</NAME>
</FUNDS>
.
.
.As you can see (hopefully) I am able to get the data I need but cannot get:
(1) the FUNDS tag(s) to be the very highest level/root.
nor (2) the SYMBOL part (tag label?) to be the actual variable stock fund.

Am I 'splaining this well enough? I don't necessarily need all the code, since I know I haven't given enough info to help with that, but my basic question is - - Is it possible to get a variable TAG based on the table DATA?

I want my SYMBOL tag to be the actual SYMBOL for the stock fund.

Confused? Not as much as I am *LOL* I am new to the use of all but XML EXPLICIT use, so any help would be appreciated - at least regarding my two formatting questions.

Yes, I have (and am still) searching around BOL for my answers, but so I have found nothing that helps me out. Meanwhile, suggestions are welcome!

Thanks!|||Thanks for the reply.

I was afraid of that. The previous version of the product used a C++ program to generate the XML (or pseudo-XML) output. I was hoping it was just because the developer didn't know how to use the XML extraction stuff in SQL Server. *sigh*

Oh well, I guess I get to gain some C# practice, as the C++ application has the source of the data "hard coded" in the logic, and we need to use a predefined, "standard" linked server reference (aka "alias").|||"Can't be Done"?

The three words I tell developers to never let me hear, otherwise I bring out the baseball bat

Dude, you know the drill

DDL, DML, I gues we got the expected results already...|||Never mind...but I'm only guessing...

USE Northwind
GO

CREATE TABLE myTable99(FundSymbol char(5), FundName varchar(255))
GO

INSERT INTO myTable99(FundSymbol, FundName)
SELECT 'AMRGX', 'AMERICAN GROWTH D' UNION ALL
SELECT 'AHERX', 'AHERX HERITAGE FUND' UNION ALL
SELECT 'AMRVX', 'AMERICAN INVESTORS GROWTH FUND'

SELECT XML_Output
FROM (
SELECT '<?xml version="1.0" encoding="utf-8"?>' AS XML_Output, 1 AS XML_Group, Null AS FundSymbol
UNION ALL
SELECT '<FUNDS>'AS XML_Output, 2 AS XML_Group, Null AS FundSymbol
UNION ALL
SELECT REPLICATE(' ',20)+'<'+FundSymbol+'>'+CHAR(13)+CHAR(10)
+ REPLICATE(' ',40)+'<NAME>'+FundName+'</NAME>'+CHAR(13)+CHAR(10)
+ REPLICATE(' ',20)+'</'+FundSymbol+'>'+CHAR(13)+CHAR(10)AS XML_Output
, 3 AS XML_Group, FundSymbol
FROM myTable99
UNION ALL
SELECT '<FUNDS>'AS XML_Output, 4 AS XML_Group, Null AS FundSymbol
) AS XXX
ORDER BY XML_Group, FundSymbol
GO

DROP TABLE myTable99
GO|||*sigh* What can I say? Every day you guys amaze me more-n-more :)

That's EXACLY what I was a-lookin for! I appreciate you doing my homework for me *hanging head* I tend to forget the usefullness of UNION, and have yet to use "REPLICATE", so now I need to go look THAT one up in BOL so that I can once again expand my horizons just a little more.

Funny (to me, anyway) that because every other application in our world here that creates XML output uses the FOR XML directive to create the output, that I get tunnel vision and just can't seem to see the easy answer lies in "standard" SQL. I guess kinda like my kids, who can't seem to get their heads around the ideas that (a) you can make your own ice cream, (b)clothes can come from a sewing machine instead of a store, (c) there's a way to change your oil without going to Jiffy Lube, and myriad other such examples of "OMG, you mean you can do that the old-fashioned way?".

But I digress...Thanks once again, Brett, for taking the time and effort to plainly show how I can get around yet another stumbling block.

It's too bad though, that since it can't be done, I will have to disregard your fantasy code and open my C# book. ;)

Thanks again!|||A mere trifle...

I was interested, because of a discussion I had with a Java developer.

If I could deliver the content in a manner like you are looking for, then the development life cycle for java gets cut in half.

I'm just exploring this now, but I was leaning on having metadata stored in the database, where I could configure all of the results via table.

Each element would have it's own properties stored.

So if the don't like the text to be black, I can make it red, on the fly. No application release headaches.

I was going to extend that and see if I could also incorporate the style sheets in the database as well..

FOR XML...what a bunch of crap

creating xml file from sql server

i am very new at this xml thing, however, i know how to develop sql. i woul
d
like to write a simple sql statement (using one table) and generate/create a
n
XML FILE that i can save onto my desktop. does anyone have any advice'I have had limited success by doing...
osql -E -S(servername) -d(database name) -H-1 -Q "select * from tablename
for xml auto" -ooutput.xml
But the XML generated is rough. So therefore I posted a similiar question,
amazingly within minutes of yours...
"snickerskid" wrote:

> i am very new at this xml thing, however, i know how to develop sql. i wo
uld
> like to write a simple sql statement (using one table) and generate/create
an
> XML FILE that i can save onto my desktop. does anyone have any advice'|||Write an ADO or ADO.net based client program that opens a connection, sends
a FOR XML query over the command stream object, sets the root property on
the result stream and then pipes the result into a file.
HTH
Michael
"snickerskid" <snickerskid@.discussions.microsoft.com> wrote in message
news:10A92994-301F-4AF2-80DF-1F8E521F7758@.microsoft.com...
>i am very new at this xml thing, however, i know how to develop sql. i
>would
> like to write a simple sql statement (using one table) and generate/create
> an
> XML FILE that i can save onto my desktop. does anyone have any advice'|||See "Retrieving and Writing XML Data" in Sql Server books online.
Also, www.sqlxml.org has some good information and examples.
Andrew Conrad
Microsoft Corp
http://blogs.msdn.com/aconrad|||Try this link...
http://www.PerfectXML.com/Articles/XML/ExportSQLXML.asp
"snickerskid" wrote:

> i am very new at this xml thing, however, i know how to develop sql. i wo
uld
> like to write a simple sql statement (using one table) and generate/create
an
> XML FILE that i can save onto my desktop. does anyone have any advice'|||thanks to www.sqlxml.org this example works great:
<%
Response.ContentType = "text/xml"
Dim oCmd, sSQL
sSQL = "<root><sql:query xmlns:sql='urn:schemas-microsoft-com:xml-sql'>" & _
"select * from table for xml auto, elements</sql:query></root>"
Set oCmd = Server.CreateObject("ADODB.Command")
oCmd.ActiveConnection = "all my connection parameters"
oCmd.CommandText = sSQL
oCmd.Dialect = "{5D531CB2-E6Ed-11D2-B252-00C04F681B71}"
oCmd.Properties("Output Stream") = Response
oCmd.Execute , , 1024
Set oCmd = Nothing
%>
so once i have done this...how do you pipe the results into a file? thanks
for your patients and help. also, this takes forever to run because there
are about 50,000 records being returned...do you have any ideas for speedin
g
it up?
"Michael Rys [MSFT]" wrote:

> Write an ADO or ADO.net based client program that opens a connection, send
s
> a FOR XML query over the command stream object, sets the root property on
> the result stream and then pipes the result into a file.
> HTH
> Michael
> "snickerskid" <snickerskid@.discussions.microsoft.com> wrote in message
> news:10A92994-301F-4AF2-80DF-1F8E521F7758@.microsoft.com...
>
>|||thanks...that helped a lot...now, i just need to see some examples that pipe
the results to file. got anything up your sleeve? =)
"Chris" wrote:
> Try this link...
> http://www.PerfectXML.com/Articles/XML/ExportSQLXML.asp
> "snickerskid" wrote:
>|||Here are some examples:
http://www.sqlteam.com/Forums/topic...D=5&CAT_ID=3&To
pic_Title=SQL+Server+2000+XML&Forum_Title=Developer
http://www.sqlxml.org/faqs.aspx?faq=29
Andrew Conrad
Microsoft Corp

creating xml file from sql server

i am very new at this xml thing, however, i know how to develop sql. i would
like to write a simple sql statement (using one table) and generate/create an
XML FILE that i can save onto my desktop. does anyone have any advice?
I have had limited success by doing...
osql -E -S(servername) -d(database name) -H-1 -Q "select * from tablename
for xml auto" -ooutput.xml
But the XML generated is rough. So therefore I posted a similiar question,
amazingly within minutes of yours...
"snickerskid" wrote:

> i am very new at this xml thing, however, i know how to develop sql. i would
> like to write a simple sql statement (using one table) and generate/create an
> XML FILE that i can save onto my desktop. does anyone have any advice?
|||Write an ADO or ADO.net based client program that opens a connection, sends
a FOR XML query over the command stream object, sets the root property on
the result stream and then pipes the result into a file.
HTH
Michael
"snickerskid" <snickerskid@.discussions.microsoft.com> wrote in message
news:10A92994-301F-4AF2-80DF-1F8E521F7758@.microsoft.com...
>i am very new at this xml thing, however, i know how to develop sql. i
>would
> like to write a simple sql statement (using one table) and generate/create
> an
> XML FILE that i can save onto my desktop. does anyone have any advice?
|||See "Retrieving and Writing XML Data" in Sql Server books online.
Also, www.sqlxml.org has some good information and examples.
Andrew Conrad
Microsoft Corp
http://blogs.msdn.com/aconrad
|||Try this link...
http://www.PerfectXML.com/Articles/XML/ExportSQLXML.asp
"snickerskid" wrote:

> i am very new at this xml thing, however, i know how to develop sql. i would
> like to write a simple sql statement (using one table) and generate/create an
> XML FILE that i can save onto my desktop. does anyone have any advice?
|||thanks to www.sqlxml.org this example works great:
<%
Response.ContentType = "text/xml"
Dim oCmd, sSQL
sSQL = "<root><sql:query xmlns:sql='urn:schemas-microsoft-com:xml-sql'>" & _
"select * from table for xml auto, elements</sql:query></root>"
Set oCmd = Server.CreateObject("ADODB.Command")
oCmd.ActiveConnection = "all my connection parameters"
oCmd.CommandText = sSQL
oCmd.Dialect = "{5D531CB2-E6Ed-11D2-B252-00C04F681B71}"
oCmd.Properties("Output Stream") = Response
oCmd.Execute , , 1024
Set oCmd = Nothing
%>
so once i have done this...how do you pipe the results into a file? thanks
for your patients and help. also, this takes forever to run because there
are about 50,000 records being returned...do you have any ideas for speeding
it up?
"Michael Rys [MSFT]" wrote:

> Write an ADO or ADO.net based client program that opens a connection, sends
> a FOR XML query over the command stream object, sets the root property on
> the result stream and then pipes the result into a file.
> HTH
> Michael
> "snickerskid" <snickerskid@.discussions.microsoft.com> wrote in message
> news:10A92994-301F-4AF2-80DF-1F8E521F7758@.microsoft.com...
>
>
|||thanks...that helped a lot...now, i just need to see some examples that pipe
the results to file. got anything up your sleeve? =)
"Chris" wrote:
[vbcol=seagreen]
> Try this link...
> http://www.PerfectXML.com/Articles/XML/ExportSQLXML.asp
> "snickerskid" wrote:
|||Here are some examples:
http://www.sqlteam.com/Forums/topic...=5&CAT_ID=3&To
pic_Title=SQL+Server+2000+XML&Forum_Title=Develope r
http://www.sqlxml.org/faqs.aspx?faq=29
Andrew Conrad
Microsoft Corp

Sunday, March 25, 2012

Creating TXT files

Can I use SQL Server to create a txt file on the c drive. Can sql server do nay kind of file handling. Is there a command that i can use in my background job to automatically create a txt file that will show data from a particular table.

Never done it before .. Any ideas...

Help is appreciated.

ThanksIn the job step, choose type as OS command(CmdExec), in the command box, type:

osql -E -Q"select top 10 * from sysobjects" -o"c:\output.txt"

The output file is a txt format having the 10 rows in sysobjects table.|||or bcp, dts or echo|||I am using BCP and it works just fine. I get a txt file with tab seperated fields. Can i specify the character positions or lengths of each field so that all my fields line up at the same positions.

Help is appreciated.

I created a stored procedure with the below
declare @.filename varchar(50),
@.bcpcommand varchar(2000)

set @.filename = 'c:\report\media.txt'
print @.filename
set @.bcpcommand = 'bcp "select * from table" queryout "'+ @.filename -U -P'
exec master..xp_cmdshell @.bcpCommandsql

Thursday, March 22, 2012

creating text files using bcp

I am using BCP and it works just fine. I get a txt file with tab seperated fields. Can i specify the character positions or lengths of each field so that all my fields line up at the same positions.

Help is appreciated.

I created a stored procedure with the below
declare @.filename varchar(50),
@.bcpcommand varchar(2000)

set @.filename = 'c:\report\media.txt'
print @.filename
set @.bcpcommand = 'bcp "select * from table" queryout "'+ @.filename -U -P'
exec master..xp_cmdshell @.bcpCommandYou could format your select as needed.|||Can u elaborate more ...how do i format my sql to seperate the fields.

like i want one field on position 1-10 and the seond from position 11-40 and so on...

Thanks|||Originally posted by hp1000
Can u elaborate more ...how do i format my sql to seperate the fields.

like i want one field on position 1-10 and the seond from position 11-40 and so on...

Thanks
Just create one long field or as many as you need like this:

select field1+replicate(' ',25-datalength(field1)+...
from table|||I am using

set @.bcpcommand = 'bcp "select medium_name + replicate(' ',10-datalength(medium_name)) from database..report_tbl" queryout "'+ @.filename + '" -U sa -P -c'

I get Line 6: Incorrect syntax near '

How can i escape the single quotes

Please help

Thsi method should work for what i want to do .

Thanks|||Originally posted by snail
Just create one long field or as many as you need like this:

select field1+replicate(' ',25-datalength(field1)+...
from table

I am using the above but it does not work with NULL values . How do i make it to work with null values. Help is very much appreciated.

Thanks|||If you attempt to format your fields within BCP...QUERYOUT you may very quickly reach the limitation on the length of the command line (I don't remember what it is, but you can check.)

What you can do instead, is create a stored procedure where you'd format whatever and whichever way you want, and in your BCP specify a call to that procedure along with QUERYOUT.|||Here's how I do it - much easier to read and manage changes.

Much like a structure or type, I create a temporary table in a stored procedure (TABLE vars won't work, as BCP won;t be able to see them), using CHAR data types, one field for each output field. I have a user-defined function for zero-padding, and one for right-justifying (space padding). I populate that table with all my data, then do a BCP statement consisting of SELECT field1 + field2 + field3 etc.

This gives my the spacing I want, and that one create table at the beginning of the procedure allows me to easily control the number spaces each field gets.

I can post a proc if it would be easier to understand.

-b|||My table def looks like this (for an SAP feed):

CREATE TABLE ##sap_table(sales_organization CHAR(4) NOT NULL,
distribution_channel CHAR(2) NOT NULL,
division CHAR(2) NOT NULL,
filler_1 CHAR(2) NOT NULL,
sold_to CHAR(8) NOT NULL,
delivering_plant CHAR(4) NOT NULL,
profit_center CHAR(10) NOT NULL,
material_code CHAR(10) NOT NULL,
pricing_date CHAR(8) NOT NULL,
charge_type CHAR(4) NOT NULL,
order_reason CHAR(3) NOT NULL,
project_number CHAR(24) NOT NULL,
contract_number CHAR(10) NOT NULL,
purchase_order_number CHAR(12) NOT NULL,
internal_sales_reference CHAR(12) NOT NULL,
usage_type CHAR(3) NOT NULL,
usage_detail CHAR(60) NOT NULL,
requestor_name CHAR(40) NOT NULL,
user_number CHAR(10) NOT NULL,
[user_name] CHAR(40) NOT NULL,
comments CHAR(100) NULL,
quantity CHAR(15) NOT NULL,
unit_of_measure CHAR(3) NOT NULL,
currency CHAR(5) NOT NULL,
extended_amount CHAR(15) NOT NULL,
customer_cost_object CHAR(40) NOT NULL,
cco_flag CHAR(3) NOT NULL,
xy_flag CHAR(1) NOT NULL,
filler_2 CHAR(6) NOT NULL )|||If you want fixed width data, why not use a format file?|||Thanks for all ur feedback . I am using coalesce and datalength functions and it did the trick.

I create a view with the fields i want in the format i want and then do the select on the view with my bcp and it writes to the text file just fine.

Thanks a lot,

Creating Text File from Stored Procedure

Greetings,

I have a sp that dumps text into a textfile but I am having trouble
creating the textfile.

EXEC master.dbo.xp_cmdShell '\\servername\d$\The File\sub\filename.dat'

The directory "The File" has a space in it. I've tried putting the
carat ^ before the space, and putting double quotes...but I keep
getting this error

'\\servername\d$\The' is not recognized as an internal or external
command, operable program or batch file.

If I do EXEC master.dbo.xp_cmdShell '"\\servername\d$\The
File\sub\filename.dat"' I get the same thing.

If I do EXEC master.dbo.xp_cmdShell '""\\servername\d$\The
File\sub\filename.dat""' I get

'"\\servername\d$\The File\sub\filename.dat"'
is not recognized as an internal or external command, operable program
or batch file.

Does anybody see what I am doing wrong?At a quick glance, it looks like filename.dat is simply not an
executable file - what exactly are you trying to do?

Simon|||Hi

Enquote the filename with double quotes should have worked, therefore the
file may not exist or could be still open. If "\\servername\d$\The
File\sub\filename.dat" from a command prompt says the file does not exist
then it probably doesn't or permissions are wrong.

If this is a batch file you may want to use a more appropriate extension.

John

"phantom" <phantomtoe@.yahoo.com> wrote in message
news:1126224325.956647.140030@.g43g2000cwa.googlegr oups.com...
> Greetings,
> I have a sp that dumps text into a textfile but I am having trouble
> creating the textfile.
> EXEC master.dbo.xp_cmdShell '\\servername\d$\The File\sub\filename.dat'
> The directory "The File" has a space in it. I've tried putting the
> carat ^ before the space, and putting double quotes...but I keep
> getting this error
> '\\servername\d$\The' is not recognized as an internal or external
> command, operable program or batch file.
> If I do EXEC master.dbo.xp_cmdShell '"\\servername\d$\The
> File\sub\filename.dat"' I get the same thing.
> If I do EXEC master.dbo.xp_cmdShell '""\\servername\d$\The
> File\sub\filename.dat""' I get
> '"\\servername\d$\The File\sub\filename.dat"'
> is not recognized as an internal or external command, operable program
> or batch file.
> Does anybody see what I am doing wrong?|||phantom (phantomtoe@.yahoo.com) writes:
> '"\\servername\d$\The File\sub\filename.dat"'
> is not recognized as an internal or external command, operable program
> or batch file.

Windows executes files depending on the suffixes. .dat is normally not
tied to any application. Thus, Windows does not know how to run the file.

If the file is a simple command file, the extension should be .BAT.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

creating text file ?? ways

1. How can i create text file using SQL query and T SQL ?
2. How many ways are there to achieve this. ?
thnkz
--
Mahesh kumar.R~Maheshkumar.r wrote:
> 1. How can i create text file using SQL query and T SQL ?
> 2. How many ways are there to achieve this. ?
Read BOL article "Copying Data From a Query to a Data File" for more info.
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)|||http://www.aspfaq.com/2482
On 3/15/05 11:20 PM, in article evadE#dKFHA.1476@.TK2MSFTNGP09.phx.gbl,
"~Maheshkumar.r" <mfcmahesh@.hotmail.com> wrote:

> 1. How can i create text file using SQL query and T SQL ?
> 2. How many ways are there to achieve this. ?
> thnkz
> --
> Mahesh kumar.R
>|||What is that specific you would want on the text file? The data too ? or
query output? Can you elaborate. To list a few options, You can look into
Query Analyzer features of output to file. You can see bcp and osql commands
in conjuction with xp_cmdshell.
HTH,
Vinod Kumar
MCSE, DBA, MCAD, MCSD
http://www.extremeexperts.com
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp
"~Maheshkumar.r" <mfcmahesh@.hotmail.com> wrote in message
news:evadE%23dKFHA.1476@.TK2MSFTNGP09.phx.gbl...
> 1. How can i create text file using SQL query and T SQL ?
> 2. How many ways are there to achieve this. ?
> thnkz
> --
> Mahesh kumar.R
>|||thnk, Yes i want to export table > text file and few query outputs to text
file ?
"Vinod Kumar" <vinodk_sct@.NO_SPAM_hotmail.com> wrote in message
news:d18hgs$v68$1@.news01.intel.com...
> What is that specific you would want on the text file? The data too ? or
> query output? Can you elaborate. To list a few options, You can look into
> Query Analyzer features of output to file. You can see bcp and osql
commands
> in conjuction with xp_cmdshell.
> --
> HTH,
> Vinod Kumar
> MCSE, DBA, MCAD, MCSD
> http://www.extremeexperts.com
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp
> "~Maheshkumar.r" <mfcmahesh@.hotmail.com> wrote in message
> news:evadE%23dKFHA.1476@.TK2MSFTNGP09.phx.gbl...
>

Creating Tables on the Fly

I have an Access 2000 MDB with ODBC linked tables to a SQL Server 7 back
end. I currently have a selections table in the front end file which the
users use to make selections of records. The table has two fields -- primary
key (which matches primary key of main, SQL Server table), and a boolean
field. The table is linked to the main table in a heterogeneous inner join.
I'm looking to move the table to the back end, while still giving each
machine a unique set of selections. Using one large table with machine name
as part of the primary key actually slows things down. So I'm considering
using a series of tables, where each machine has its own table in the back
end for selections. The machine name would be incorporated in the particular
selections table name, and the front end link would be modified on the fly
when the database is opened to point to that machine's back end selections
table.
This would require having about 50-100 individual selections tables in the
back end database. Also, if a machine doesn't have a table when the database
is opened on that machine, then that table would be created on the fly,
populated, and pointed to via the ODBC link.
Anyone see any problems with this approach, specifically creating the table
on the fly and then immediately using it, as well as having that many little
tables running around? Thanks for any input!
Neil
> machine a unique set of selections. Using one large table with machine
> name as part of the primary key actually slows things down. So I'm
> considering
> ...
> This would require having about 50-100 individual selections tables in the
> back end database.
You have 50-100 rows in the table and you think that slows it down? Even
without a clustered index or any index at all, I find it hard to believe
that you can perceive any slowness whatsoever based on a scan of rows in the
three figure range. And to sacrifice manageability for that seems absurd,
at least to me.
|||Neil (nospam@.nospam.net) writes:
> I have an Access 2000 MDB with ODBC linked tables to a SQL Server 7 back
> end. I currently have a selections table in the front end file which the
> users use to make selections of records. The table has two fields --
> primary key (which matches primary key of main, SQL Server table), and a
> boolean field. The table is linked to the main table in a heterogeneous
> inner join.
> I'm looking to move the table to the back end, while still giving each
> machine a unique set of selections. Using one large table with machine
> name as part of the primary key actually slows things down. So I'm
> considering using a series of tables, where each machine has its own
> table in the back end for selections. The machine name would be
> incorporated in the particular selections table name, and the front end
> link would be modified on the fly when the database is opened to point
> to that machine's back end selections table.
>...
> Anyone see any problems with this approach, specifically creating the
> table on the fly and then immediately using it, as well as having that
> many little tables running around? Thanks for any input!
Yes, I see problems. Simply don't go there. This is not the way you use a
relational database. Make that machine name part of the PK in the single
table. If having one single table, slows things down, investigate why
instead of resorting to kludges.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
|||You misread my post. I said 50-100 tables, not 50-100 rows.
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:ewqxaaL3FHA.3636@.TK2MSFTNGP09.phx.gbl...
> You have 50-100 rows in the table and you think that slows it down? Even
> without a clustered index or any index at all, I find it hard to believe
> that you can perceive any slowness whatsoever based on a scan of rows in
> the three figure range. And to sacrifice manageability for that seems
> absurd, at least to me.
>
|||OK, point well taken. I don't see any workaround, though, since I'm using
ODBC linked tables. I can't use a pass-through query and pass the table name
as a parameter, because pass-throughs return read-only sets. And a view
wouldn't be able to return just the records for that machine.
Here's an idea. What if there were one table, but a series of views, with
each view returning records for a particular unique ID. When the app is
opened, it's assigned an available ID and its link is set to the view that
returns records for that ID. Still kind of a kludge, but perhaps a little
better.
"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns96FED3AD11D99Yazorman@.127.0.0.1...
> Neil (nospam@.nospam.net) writes:
> Yes, I see problems. Simply don't go there. This is not the way you use a
> relational database. Make that machine name part of the PK in the single
> table. If having one single table, slows things down, investigate why
> instead of resorting to kludges.
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techinf...2000/books.asp
>
|||You are sooooooo screwed up I have to use this in a book! I am looking
for anything you did right and I cannot find it.
[vbcol=seagreen]
field [sic] . The table is linked to the main table in a heterogeneous inner join[sic] . <<
Let's get back to the basics of an RDBMS. Rows are not records; fields
are not columns; tables are not files. These are FUNDAMENTALLY
DIFFERENT CONCEPTS. SQL does not have Boolean data types -- they woudl
screw up the 3VL that is the foundations of SQL's model.
[vbcol=seagreen]
Then these will not be the same table, will they? Duh!
[vbcol=seagreen]
Machine name? Have you ever read anything on data modeling? Logical
versus Physical? The basics!! The basics!!
[vbcol=seagreen]
Sure, split the LOGICAL design over the PHYSICAL implementation. To
hell with the foundations of RDBMS, Data Modeling , etc. You are doing
1950's tape system in SQL.
[vbcol=seagreen]
You have just implemented a design we found to be a nightmare in the
1950's with magnetic tape file names. It is one of the reasons we went
to disk systems and then to navigation database and then to RDBMs
systems.
[vbcol=seagreen]
a the ODBC link. <<
Back to basics. A table models a set of one kind of entity or a
relationship. Then schema models the reality of the data model in
those terms. Creating them on the fly is the logical equivalent of
having an elephant drp out of the sky.
[vbcol=seagreen]
Dr. Codd,. Chris Date, me, anyone in RDBMS?
Please get some help before you hurt people. Everything you are doing
is wrong
|||I don't think I did. But have fun.
"Neil" <nospam@.nospam.net> wrote in message
news:mgR8f.3506$yX2.132@.newsread2.news.pas.earthli nk.net...
> You misread my post. I said 50-100 tables, not 50-100 rows.
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
> message news:ewqxaaL3FHA.3636@.TK2MSFTNGP09.phx.gbl...
>
|||You wrote: "You have 50-100 rows in the table and you think that slows it
down?"
I never wrote that I have 50-100 rows in the table. I said I was considering
50-100 tables.
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:uJ2c5eV3FHA.3868@.TK2MSFTNGP12.phx.gbl...
>I don't think I did. But have fun.
>
>
> "Neil" <nospam@.nospam.net> wrote in message
> news:mgR8f.3506$yX2.132@.newsread2.news.pas.earthli nk.net...
>
|||"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns96FF73E7D7719Yazorman@.127.0.0.1...

> You will have to bear with me, since my knowledge of Access is so poor.
> But if I understand this correctly, you have a local table in Access
> with selections that typically has 50000 rows. And since each user
> has his own Access instance, this means that today there are some 25-50
> instances of this table.
Yes, each on its own machine.

> 13 seconds to open a form is indeed a long time, and many users would
> say a too long time.
> But moving this data to SQL server may not a very good idea at all.
> Sending
> 50000 rows over the wire is not done snap. On a local network it may be
> decently fast, but if you have a user that works from home, it will be
> a pain.
Yes, the situation is over a T1 line. The LAN users don't have any
significant delays. But the WAN users are getting long load times.

> So I would suggest that you should rather look into to load fewer rows
> into the form initially, and then fetch depending on what action the
> user takes. I can't believe that the user is looking at all 50000 at
> a time.
Well, they *work* with all 50,000, even if they don't use them. They like
being able to work in datasheet view (a spreadsheet-like representation of
data) and do sorting, filtering, editing, etc. In form view (the traditional
representation of data), I could give them one record at a time; but in
datasheet view they like to have all the records there.

> If this data is only related to the user's selection, it's probably a
> good idea to keep it local anyway. The only point I can see with moving
> it to the server, is that it could permit the user to get back his
> selection if he moves to another machine.
Well, the idea was to eliminate the heterogeneous join. And, indeed, I have
seen a performance increase in other areas of the form with the trial
back-end selections table I put in place (sorting on a field, for example,
is much faster with the selections table in the back end). The problem,
though, is that in this one area, the initial opening of the form, it
actually slows things down. And that's a key area, since users need to be
able to open the form quickly when they need the data.
Neil

> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techinf...2000/books.asp
>
|||Thanks for the tips.
Regarding HOST_NAME, yes, that would be better than passing a parameter. I
found, though, that even with the host name selected on the back end, it was
still slow with that large selections table. Even with SQL selecting the
needed 50,000 records to return (from the 1.25 mil record view), it was
still slower than having a 50,000 record table on the front end and having a
heterogeneous join with the 50,000 record table on the back end.
Neil
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:43649a11$0$23295$db0fefd9@.news.zen.co.uk...
> Hi
> I probably know less about access than Erland, but you may want to look at
> just what is happening on the SQL Server when you have everything on the
> server. SQL Profiler may give you some information that we may be missing
> and how each solution works. Also look at the Query Plans for the executed
> SQL and check your indexes are being used and that you have up-to-date
> statistics.
> You may be able to simplify things with the HOST_NAME function in your
> view.
> John
> "Neil" <nospam@.nospam.net> wrote in message
> news:cZU8f.3368$Rl1.2750@.newsread1.news.pas.earthl ink.net...
>

Creating Tables on the Fly

I have an Access 2000 MDB with ODBC linked tables to a SQL Server 7 back
end. I currently have a selections table in the front end file which the
users use to make selections of records. The table has two fields -- primary
key (which matches primary key of main, SQL Server table), and a boolean
field. The table is linked to the main table in a heterogeneous inner join.
I'm looking to move the table to the back end, while still giving each
machine a unique set of selections. Using one large table with machine name
as part of the primary key actually slows things down. So I'm considering
using a series of tables, where each machine has its own table in the back
end for selections. The machine name would be incorporated in the particular
selections table name, and the front end link would be modified on the fly
when the database is opened to point to that machine's back end selections
table.
This would require having about 50-100 individual selections tables in the
back end database. Also, if a machine doesn't have a table when the database
is opened on that machine, then that table would be created on the fly,
populated, and pointed to via the ODBC link.
Anyone see any problems with this approach, specifically creating the table
on the fly and then immediately using it, as well as having that many little
tables running around? Thanks for any input!
Neil> machine a unique set of selections. Using one large table with machine
> name as part of the primary key actually slows things down. So I'm
> considering
> ...
> This would require having about 50-100 individual selections tables in the
> back end database.
You have 50-100 rows in the table and you think that slows it down? Even
without a clustered index or any index at all, I find it hard to believe
that you can perceive any slowness whatsoever based on a scan of rows in the
three figure range. And to sacrifice manageability for that seems absurd,
at least to me.|||Neil (nospam@.nospam.net) writes:
> I have an Access 2000 MDB with ODBC linked tables to a SQL Server 7 back
> end. I currently have a selections table in the front end file which the
> users use to make selections of records. The table has two fields --
> primary key (which matches primary key of main, SQL Server table), and a
> boolean field. The table is linked to the main table in a heterogeneous
> inner join.
> I'm looking to move the table to the back end, while still giving each
> machine a unique set of selections. Using one large table with machine
> name as part of the primary key actually slows things down. So I'm
> considering using a series of tables, where each machine has its own
> table in the back end for selections. The machine name would be
> incorporated in the particular selections table name, and the front end
> link would be modified on the fly when the database is opened to point
> to that machine's back end selections table.
>...
> Anyone see any problems with this approach, specifically creating the
> table on the fly and then immediately using it, as well as having that
> many little tables running around? Thanks for any input!
Yes, I see problems. Simply don't go there. This is not the way you use a
relational database. Make that machine name part of the PK in the single
table. If having one single table, slows things down, investigate why
instead of resorting to kludges.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||You misread my post. I said 50-100 tables, not 50-100 rows.
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:ewqxaaL3FHA.3636@.TK2MSFTNGP09.phx.gbl...
> You have 50-100 rows in the table and you think that slows it down? Even
> without a clustered index or any index at all, I find it hard to believe
> that you can perceive any slowness whatsoever based on a scan of rows in
> the three figure range. And to sacrifice manageability for that seems
> absurd, at least to me.
>|||OK, point well taken. I don't see any workaround, though, since I'm using
ODBC linked tables. I can't use a pass-through query and pass the table name
as a parameter, because pass-throughs return read-only sets. And a view
wouldn't be able to return just the records for that machine.
Here's an idea. What if there were one table, but a series of views, with
each view returning records for a particular unique ID. When the app is
opened, it's assigned an available ID and its link is set to the view that
returns records for that ID. Still kind of a kludge, but perhaps a little
better.
"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns96FED3AD11D99Yazorman@.127.0.0.1...
> Neil (nospam@.nospam.net) writes:
> Yes, I see problems. Simply don't go there. This is not the way you use a
> relational database. Make that machine name part of the PK in the single
> table. If having one single table, slows things down, investigate why
> instead of resorting to kludges.
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp
>|||You are sooooooo screwed up I have to use this in a book! I am looking
for anything you did right and I cannot find it.
field [sic] . The table is linked to the main table in a heterogeneous inner join[sic]
. <<
Let's get back to the basics of an RDBMS. Rows are not records; fields
are not columns; tables are not files. These are FUNDAMENTALLY
DIFFERENT CONCEPTS. SQL does not have Boolean data types -- they woudl
screw up the 3VL that is the foundations of SQL's model.
Then these will not be the same table, will they? Duh!
Machine name' Have you ever read anything on data modeling? Logical
versus Physical' The basics!! The basics!!
Sure, split the LOGICAL design over the PHYSICAL implementation. To
hell with the foundations of RDBMS, Data Modeling , etc. You are doing
1950's tape system in SQL.
You have just implemented a design we found to be a nightmare in the
1950's with magnetic tape file names. It is one of the reasons we went
to disk systems and then to navigation database and then to RDBMs
systems.
a the ODBC link. <<
Back to basics. A table models a set of one kind of entity or a
relationship. Then schema models the reality of the data model in
those terms. Creating them on the fly is the logical equivalent of
having an elephant drp out of the sky.
Dr. Codd,. Chris Date, me, anyone in RDBMS?
Please get some help before you hurt people. Everything you are doing
is wrong|||Neil (nospam@.nospam.net) writes:
> OK, point well taken. I don't see any workaround, though, since I'm
> using ODBC linked tables. I can't use a pass-through query and pass the
> table name as a parameter, because pass-throughs return read-only sets.
> And a view wouldn't be able to return just the records for that
> machine.
As for how to sort out the linked tables, you will have to ask in an
Access newsgroup.

> Here's an idea. What if there were one table, but a series of views, with
> each view returning records for a particular unique ID. When the app is
> opened, it's assigned an available ID and its link is set to the view that
> returns records for that ID. Still kind of a kludge, but perhaps a little
> better.
A table-valued function with the machine name as parameter would be better.
But without knowing Access, I'm quite sure that this can be solved by
adding the machine name on the Access side as well. After all, that is
also an RDBMS, and should be fitted for relational solutions.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||--CELKO-- (jcelko212@.earthlink.net) writes:
> You are sooooooo screwed up I have to use this in a book! I am looking
> for anything you did right and I cannot find it.
He is nowhere near as screwed up as you are. At least Neil knows how
to behave properly and politely.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Yes, it can be done on the Access side, but, as noted, things are slowed
down. When I had a main SQL table (50,000 records) joined to a local Access
table (also 50,000 records, with an index and a boolean field), the form
took about 13 seconds to open (with the join being, of course, in the front
end).
With the new solution, the main SQL table still has 50,000 records, but, as
a sample, I populated the selections table with 50,000 x 25 records,
simulating 25 machines having records in the table. I created a view,
joining the two tables on the back end, and linked the view (with the
machine name as a field) to the front end. Using that 1,250,000 record view
with a parameter to only return the 50,000 records that match the machine
name, the form took about 17 seconds to open.
One of the reasons to move the selections table to the back end was for
speed in opening the form. But the resulting 1.25 mil record table is
slowing things down than the smaller table in the front end did, even with a
heterogeneous join.
Thus, I'm left with no solution, unless I can use a smaller table, of if
there's something I haven't seen re. using the view in Access (which I don't
think there is).
Neil
"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns96FF7327EABEYazorman@.127.0.0.1...
> Neil (nospam@.nospam.net) writes:
> As for how to sort out the linked tables, you will have to ask in an
> Access newsgroup.
>
> A table-valued function with the machine name as parameter would be
> better.
> But without knowing Access, I'm quite sure that this can be solved by
> adding the machine name on the Access side as well. After all, that is
> also an RDBMS, and should be fitted for relational solutions.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp
>|||Hi
I probably know less about access than Erland, but you may want to look at
just what is happening on the SQL Server when you have everything on the
server. SQL Profiler may give you some information that we may be missing
and how each solution works. Also look at the Query Plans for the executed
SQL and check your indexes are being used and that you have up-to-date
statistics.
You may be able to simplify things with the HOST_NAME function in your view.
John
"Neil" <nospam@.nospam.net> wrote in message
news:cZU8f.3368$Rl1.2750@.newsread1.news.pas.earthlink.net...
> Yes, it can be done on the Access side, but, as noted, things are slowed
> down. When I had a main SQL table (50,000 records) joined to a local
> Access table (also 50,000 records, with an index and a boolean field), the
> form took about 13 seconds to open (with the join being, of course, in the
> front end).
> With the new solution, the main SQL table still has 50,000 records, but,
> as a sample, I populated the selections table with 50,000 x 25 records,
> simulating 25 machines having records in the table. I created a view,
> joining the two tables on the back end, and linked the view (with the
> machine name as a field) to the front end. Using that 1,250,000 record
> view with a parameter to only return the 50,000 records that match the
> machine name, the form took about 17 seconds to open.
> One of the reasons to move the selections table to the back end was for
> speed in opening the form. But the resulting 1.25 mil record table is
> slowing things down than the smaller table in the front end did, even with
> a heterogeneous join.
> Thus, I'm left with no solution, unless I can use a smaller table, of if
> there's something I haven't seen re. using the view in Access (which I
> don't think there is).
> Neil
>
> "Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
> news:Xns96FF7327EABEYazorman@.127.0.0.1...
>

Creating Tables on the Fly

I have an Access 2000 MDB with ODBC linked tables to a SQL Server 7 back
end. I currently have a selections table in the front end file which the
users use to make selections of records. The table has two fields -- primary
key (which matches primary key of main, SQL Server table), and a boolean
field. The table is linked to the main table in a heterogeneous inner join.

I'm looking to move the table to the back end, while still giving each
machine a unique set of selections. Using one large table with machine name
as part of the primary key actually slows things down. So I'm considering
using a series of tables, where each machine has its own table in the back
end for selections. The machine name would be incorporated in the particular
selections table name, and the front end link would be modified on the fly
when the database is opened to point to that machine's back end selections
table.

This would require having about 50-100 individual selections tables in the
back end database. Also, if a machine doesn't have a table when the database
is opened on that machine, then that table would be created on the fly,
populated, and pointed to via the ODBC link.

Anyone see any problems with this approach, specifically creating the table
on the fly and then immediately using it, as well as having that many little
tables running around? Thanks for any input!

Neil> machine a unique set of selections. Using one large table with machine
> name as part of the primary key actually slows things down. So I'm
> considering
> ...
> This would require having about 50-100 individual selections tables in the
> back end database.

You have 50-100 rows in the table and you think that slows it down? Even
without a clustered index or any index at all, I find it hard to believe
that you can perceive any slowness whatsoever based on a scan of rows in the
three figure range. And to sacrifice manageability for that seems absurd,
at least to me.|||Neil (nospam@.nospam.net) writes:
> I have an Access 2000 MDB with ODBC linked tables to a SQL Server 7 back
> end. I currently have a selections table in the front end file which the
> users use to make selections of records. The table has two fields --
> primary key (which matches primary key of main, SQL Server table), and a
> boolean field. The table is linked to the main table in a heterogeneous
> inner join.
> I'm looking to move the table to the back end, while still giving each
> machine a unique set of selections. Using one large table with machine
> name as part of the primary key actually slows things down. So I'm
> considering using a series of tables, where each machine has its own
> table in the back end for selections. The machine name would be
> incorporated in the particular selections table name, and the front end
> link would be modified on the fly when the database is opened to point
> to that machine's back end selections table.
>...
> Anyone see any problems with this approach, specifically creating the
> table on the fly and then immediately using it, as well as having that
> many little tables running around? Thanks for any input!

Yes, I see problems. Simply don't go there. This is not the way you use a
relational database. Make that machine name part of the PK in the single
table. If having one single table, slows things down, investigate why
instead of resorting to kludges.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||You misread my post. I said 50-100 tables, not 50-100 rows.

"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:ewqxaaL3FHA.3636@.TK2MSFTNGP09.phx.gbl...
>> machine a unique set of selections. Using one large table with machine
>> name as part of the primary key actually slows things down. So I'm
>> considering
>> ...
>>
>> This would require having about 50-100 individual selections tables in
>> the back end database.
> You have 50-100 rows in the table and you think that slows it down? Even
> without a clustered index or any index at all, I find it hard to believe
> that you can perceive any slowness whatsoever based on a scan of rows in
> the three figure range. And to sacrifice manageability for that seems
> absurd, at least to me.|||OK, point well taken. I don't see any workaround, though, since I'm using
ODBC linked tables. I can't use a pass-through query and pass the table name
as a parameter, because pass-throughs return read-only sets. And a view
wouldn't be able to return just the records for that machine.

Here's an idea. What if there were one table, but a series of views, with
each view returning records for a particular unique ID. When the app is
opened, it's assigned an available ID and its link is set to the view that
returns records for that ID. Still kind of a kludge, but perhaps a little
better.

"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns96FED3AD11D99Yazorman@.127.0.0.1...
> Neil (nospam@.nospam.net) writes:
>> I have an Access 2000 MDB with ODBC linked tables to a SQL Server 7 back
>> end. I currently have a selections table in the front end file which the
>> users use to make selections of records. The table has two fields --
>> primary key (which matches primary key of main, SQL Server table), and a
>> boolean field. The table is linked to the main table in a heterogeneous
>> inner join.
>>
>> I'm looking to move the table to the back end, while still giving each
>> machine a unique set of selections. Using one large table with machine
>> name as part of the primary key actually slows things down. So I'm
>> considering using a series of tables, where each machine has its own
>> table in the back end for selections. The machine name would be
>> incorporated in the particular selections table name, and the front end
>> link would be modified on the fly when the database is opened to point
>> to that machine's back end selections table.
>>...
>> Anyone see any problems with this approach, specifically creating the
>> table on the fly and then immediately using it, as well as having that
>> many little tables running around? Thanks for any input!
> Yes, I see problems. Simply don't go there. This is not the way you use a
> relational database. Make that machine name part of the PK in the single
> table. If having one single table, slows things down, investigate why
> instead of resorting to kludges.
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp|||You are sooooooo screwed up I have to use this in a book! I am looking
for anything you did right and I cannot find it.

>> I currently have a selections table in the front end file [sic] which the users use to make selections of records [sic] . The table has two fields [sic] -- primary key (which matches primary key of main [sic] SQL Server table), and a Boolean [sic] field [sic] . The table is linked to the main table in a heterogeneous inner join[sic] . <<

Let's get back to the basics of an RDBMS. Rows are not records; fields
are not columns; tables are not files. These are FUNDAMENTALLY
DIFFERENT CONCEPTS. SQL does not have Boolean data types -- they woudl
screw up the 3VL that is the foundations of SQL's model.

>> I'm looking to move the table to the back end, while still giving each machine a unique set of selections. <<

Then these will not be the same table, will they? Duh!

>> Using one large table with machine name as part of the primary key actually slows things down. <<

Machine name?? Have you ever read anything on data modeling? Logical
versus Physical?? The basics!! The basics!!

>> So I'm considering using a series of tables, where each machine has its own table in the back end for selections. <<

Sure, split the LOGICAL design over the PHYSICAL implementation. To
hell with the foundations of RDBMS, Data Modeling , etc. You are doing
1950's tape system in SQL.

>> The machine name would be incorporated in the particular selections table name, and the front end link would be modified on the fly when the database is opened to point to that machine's back end selections table. <<

You have just implemented a design we found to be a nightmare in the
1950's with magnetic tape file names. It is one of the reasons we went
to disk systems and then to navigation database and then to RDBMs
systems.

>> This would require having about 50-100 individual selections tables in the back end database. Also, if a machine doesn't have a table when the database is opened on that machine, then that table would be created on the fly, populated, and pointed to via the ODBC link. <<

Back to basics. A table models a set of one kind of entity or a
relationship. Then schema models the reality of the data model in
those terms. Creating them on the fly is the logical equivalent of
having an elephant drp out of the sky.

>> Anyone see any problems with this approach, specifically creating the table on the fly and then immediately using it, as well as having that many little tables running around? <<

Dr. Codd,. Chris Date, me, anyone in RDBMS?

Please get some help before you hurt people. Everything you are doing
is wrong|||Neil (nospam@.nospam.net) writes:
> OK, point well taken. I don't see any workaround, though, since I'm
> using ODBC linked tables. I can't use a pass-through query and pass the
> table name as a parameter, because pass-throughs return read-only sets.
> And a view wouldn't be able to return just the records for that
> machine.

As for how to sort out the linked tables, you will have to ask in an
Access newsgroup.

> Here's an idea. What if there were one table, but a series of views, with
> each view returning records for a particular unique ID. When the app is
> opened, it's assigned an available ID and its link is set to the view that
> returns records for that ID. Still kind of a kludge, but perhaps a little
> better.

A table-valued function with the machine name as parameter would be better.
But without knowing Access, I'm quite sure that this can be solved by
adding the machine name on the Access side as well. After all, that is
also an RDBMS, and should be fitted for relational solutions.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||--CELKO-- (jcelko212@.earthlink.net) writes:
> You are sooooooo screwed up I have to use this in a book! I am looking
> for anything you did right and I cannot find it.

He is nowhere near as screwed up as you are. At least Neil knows how
to behave properly and politely.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Yes, it can be done on the Access side, but, as noted, things are slowed
down. When I had a main SQL table (50,000 records) joined to a local Access
table (also 50,000 records, with an index and a boolean field), the form
took about 13 seconds to open (with the join being, of course, in the front
end).

With the new solution, the main SQL table still has 50,000 records, but, as
a sample, I populated the selections table with 50,000 x 25 records,
simulating 25 machines having records in the table. I created a view,
joining the two tables on the back end, and linked the view (with the
machine name as a field) to the front end. Using that 1,250,000 record view
with a parameter to only return the 50,000 records that match the machine
name, the form took about 17 seconds to open.

One of the reasons to move the selections table to the back end was for
speed in opening the form. But the resulting 1.25 mil record table is
slowing things down than the smaller table in the front end did, even with a
heterogeneous join.

Thus, I'm left with no solution, unless I can use a smaller table, of if
there's something I haven't seen re. using the view in Access (which I don't
think there is).

Neil

"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns96FF7327EABEYazorman@.127.0.0.1...
> Neil (nospam@.nospam.net) writes:
>> OK, point well taken. I don't see any workaround, though, since I'm
>> using ODBC linked tables. I can't use a pass-through query and pass the
>> table name as a parameter, because pass-throughs return read-only sets.
>> And a view wouldn't be able to return just the records for that
>> machine.
> As for how to sort out the linked tables, you will have to ask in an
> Access newsgroup.
>> Here's an idea. What if there were one table, but a series of views, with
>> each view returning records for a particular unique ID. When the app is
>> opened, it's assigned an available ID and its link is set to the view
>> that
>> returns records for that ID. Still kind of a kludge, but perhaps a little
>> better.
> A table-valued function with the machine name as parameter would be
> better.
> But without knowing Access, I'm quite sure that this can be solved by
> adding the machine name on the Access side as well. After all, that is
> also an RDBMS, and should be fitted for relational solutions.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp|||Hi

I probably know less about access than Erland, but you may want to look at
just what is happening on the SQL Server when you have everything on the
server. SQL Profiler may give you some information that we may be missing
and how each solution works. Also look at the Query Plans for the executed
SQL and check your indexes are being used and that you have up-to-date
statistics.

You may be able to simplify things with the HOST_NAME function in your view.

John

"Neil" <nospam@.nospam.net> wrote in message
news:cZU8f.3368$Rl1.2750@.newsread1.news.pas.earthl ink.net...
> Yes, it can be done on the Access side, but, as noted, things are slowed
> down. When I had a main SQL table (50,000 records) joined to a local
> Access table (also 50,000 records, with an index and a boolean field), the
> form took about 13 seconds to open (with the join being, of course, in the
> front end).
> With the new solution, the main SQL table still has 50,000 records, but,
> as a sample, I populated the selections table with 50,000 x 25 records,
> simulating 25 machines having records in the table. I created a view,
> joining the two tables on the back end, and linked the view (with the
> machine name as a field) to the front end. Using that 1,250,000 record
> view with a parameter to only return the 50,000 records that match the
> machine name, the form took about 17 seconds to open.
> One of the reasons to move the selections table to the back end was for
> speed in opening the form. But the resulting 1.25 mil record table is
> slowing things down than the smaller table in the front end did, even with
> a heterogeneous join.
> Thus, I'm left with no solution, unless I can use a smaller table, of if
> there's something I haven't seen re. using the view in Access (which I
> don't think there is).
> Neil
>
> "Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
> news:Xns96FF7327EABEYazorman@.127.0.0.1...
>> Neil (nospam@.nospam.net) writes:
>>> OK, point well taken. I don't see any workaround, though, since I'm
>>> using ODBC linked tables. I can't use a pass-through query and pass the
>>> table name as a parameter, because pass-throughs return read-only sets.
>>> And a view wouldn't be able to return just the records for that
>>> machine.
>>
>> As for how to sort out the linked tables, you will have to ask in an
>> Access newsgroup.
>>
>>> Here's an idea. What if there were one table, but a series of views,
>>> with
>>> each view returning records for a particular unique ID. When the app is
>>> opened, it's assigned an available ID and its link is set to the view
>>> that
>>> returns records for that ID. Still kind of a kludge, but perhaps a
>>> little
>>> better.
>>
>> A table-valued function with the machine name as parameter would be
>> better.
>> But without knowing Access, I'm quite sure that this can be solved by
>> adding the machine name on the Access side as well. After all, that is
>> also an RDBMS, and should be fitted for relational solutions.
>>
>>
>>
>> --
>> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
>>
>> Books Online for SQL Server SP3 at
>> http://www.microsoft.com/sql/techin.../2000/books.asp
>>|||Neil (nospam@.nospam.net) writes:
> Yes, it can be done on the Access side, but, as noted, things are slowed
> down. When I had a main SQL table (50,000 records) joined to a local
> Access table (also 50,000 records, with an index and a boolean field),
> the form took about 13 seconds to open (with the join being, of course,
> in the front end).
> With the new solution, the main SQL table still has 50,000 records, but,
> as a sample, I populated the selections table with 50,000 x 25 records,
> simulating 25 machines having records in the table. I created a view,
> joining the two tables on the back end, and linked the view (with the
> machine name as a field) to the front end. Using that 1,250,000 record
> view with a parameter to only return the 50,000 records that match the
> machine name, the form took about 17 seconds to open.
> One of the reasons to move the selections table to the back end was for
> speed in opening the form. But the resulting 1.25 mil record table is
> slowing things down than the smaller table in the front end did, even
> with a heterogeneous join.
> Thus, I'm left with no solution, unless I can use a smaller table, of if
> there's something I haven't seen re. using the view in Access (which I
> don't think there is).

You will have to bear with me, since my knowledge of Access is so poor.

But if I understand this correctly, you have a local table in Access
with selections that typically has 50000 rows. And since each user
has his own Access instance, this means that today there are some 25-50
instances of this table.

13 seconds to open a form is indeed a long time, and many users would
say a too long time.

But moving this data to SQL server may not a very good idea at all. Sending
50000 rows over the wire is not done snap. On a local network it may be
decently fast, but if you have a user that works from home, it will be
a pain.

So I would suggest that you should rather look into to load fewer rows
into the form initially, and then fetch depending on what action the
user takes. I can't believe that the user is looking at all 50000 at
a time.

If this data is only related to the user's selection, it's probably a
good idea to keep it local anyway. The only point I can see with moving
it to the server, is that it could permit the user to get back his
selection if he moves to another machine.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||On Sun, 30 Oct 2005 01:03:04 GMT, "Neil" <nospam@.nospam.net> wrote:

>Yes, it can be done on the Access side, but, as noted, things are slowed
>down. When I had a main SQL table (50,000 records) joined to a local Access
>table (also 50,000 records, with an index and a boolean field), the form
>took about 13 seconds to open (with the join being, of course, in the front
>end).

You really need to read up on the performance issues of using Access as a
front-end to SQL Server. There are a few basic rules to know, (such as making
sure join fields are indexed, and every table has a primary key) but if you
follow them all, you should not have the performance issues you are
describing.

I routinely just build plain ol' Access queries that use criteria and join
muliple linked tables together. JET is smart enough to build prepared
statements and process the joins at the server side, so performance is pretty
good.|||I don't think I did. But have fun.

"Neil" <nospam@.nospam.net> wrote in message
news:mgR8f.3506$yX2.132@.newsread2.news.pas.earthli nk.net...
> You misread my post. I said 50-100 tables, not 50-100 rows.
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
> message news:ewqxaaL3FHA.3636@.TK2MSFTNGP09.phx.gbl...
>>> machine a unique set of selections. Using one large table with machine
>>> name as part of the primary key actually slows things down. So I'm
>>> considering
>>> ...
>>>
>>> This would require having about 50-100 individual selections tables in
>>> the back end database.
>>
>> You have 50-100 rows in the table and you think that slows it down? Even
>> without a clustered index or any index at all, I find it hard to believe
>> that you can perceive any slowness whatsoever based on a scan of rows in
>> the three figure range. And to sacrifice manageability for that seems
>> absurd, at least to me.
>>|||You wrote: "You have 50-100 rows in the table and you think that slows it
down?"

I never wrote that I have 50-100 rows in the table. I said I was considering
50-100 tables.

"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:uJ2c5eV3FHA.3868@.TK2MSFTNGP12.phx.gbl...
>I don't think I did. But have fun.
>
>
> "Neil" <nospam@.nospam.net> wrote in message
> news:mgR8f.3506$yX2.132@.newsread2.news.pas.earthli nk.net...
>> You misread my post. I said 50-100 tables, not 50-100 rows.
>>
>> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in
>> message news:ewqxaaL3FHA.3636@.TK2MSFTNGP09.phx.gbl...
>>>> machine a unique set of selections. Using one large table with machine
>>>> name as part of the primary key actually slows things down. So I'm
>>>> considering
>>>> ...
>>>>
>>>> This would require having about 50-100 individual selections tables in
>>>> the back end database.
>>>
>>> You have 50-100 rows in the table and you think that slows it down?
>>> Even without a clustered index or any index at all, I find it hard to
>>> believe that you can perceive any slowness whatsoever based on a scan of
>>> rows in the three figure range. And to sacrifice manageability for that
>>> seems absurd, at least to me.
>>>
>>
>>|||"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns96FF73E7D7719Yazorman@.127.0.0.1...

> You will have to bear with me, since my knowledge of Access is so poor.
> But if I understand this correctly, you have a local table in Access
> with selections that typically has 50000 rows. And since each user
> has his own Access instance, this means that today there are some 25-50
> instances of this table.

Yes, each on its own machine.

> 13 seconds to open a form is indeed a long time, and many users would
> say a too long time.
> But moving this data to SQL server may not a very good idea at all.
> Sending
> 50000 rows over the wire is not done snap. On a local network it may be
> decently fast, but if you have a user that works from home, it will be
> a pain.

Yes, the situation is over a T1 line. The LAN users don't have any
significant delays. But the WAN users are getting long load times.

> So I would suggest that you should rather look into to load fewer rows
> into the form initially, and then fetch depending on what action the
> user takes. I can't believe that the user is looking at all 50000 at
> a time.

Well, they *work* with all 50,000, even if they don't use them. They like
being able to work in datasheet view (a spreadsheet-like representation of
data) and do sorting, filtering, editing, etc. In form view (the traditional
representation of data), I could give them one record at a time; but in
datasheet view they like to have all the records there.

> If this data is only related to the user's selection, it's probably a
> good idea to keep it local anyway. The only point I can see with moving
> it to the server, is that it could permit the user to get back his
> selection if he moves to another machine.

Well, the idea was to eliminate the heterogeneous join. And, indeed, I have
seen a performance increase in other areas of the form with the trial
back-end selections table I put in place (sorting on a field, for example,
is much faster with the selections table in the back end). The problem,
though, is that in this one area, the initial opening of the form, it
actually slows things down. And that's a key area, since users need to be
able to open the form quickly when they need the data.

Neil

> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp|||Thanks for the tips.

Regarding HOST_NAME, yes, that would be better than passing a parameter. I
found, though, that even with the host name selected on the back end, it was
still slow with that large selections table. Even with SQL selecting the
needed 50,000 records to return (from the 1.25 mil record view), it was
still slower than having a 50,000 record table on the front end and having a
heterogeneous join with the 50,000 record table on the back end.

Neil

"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:43649a11$0$23295$db0fefd9@.news.zen.co.uk...
> Hi
> I probably know less about access than Erland, but you may want to look at
> just what is happening on the SQL Server when you have everything on the
> server. SQL Profiler may give you some information that we may be missing
> and how each solution works. Also look at the Query Plans for the executed
> SQL and check your indexes are being used and that you have up-to-date
> statistics.
> You may be able to simplify things with the HOST_NAME function in your
> view.
> John
> "Neil" <nospam@.nospam.net> wrote in message
> news:cZU8f.3368$Rl1.2750@.newsread1.news.pas.earthl ink.net...
>> Yes, it can be done on the Access side, but, as noted, things are slowed
>> down. When I had a main SQL table (50,000 records) joined to a local
>> Access table (also 50,000 records, with an index and a boolean field),
>> the form took about 13 seconds to open (with the join being, of course,
>> in the front end).
>>
>> With the new solution, the main SQL table still has 50,000 records, but,
>> as a sample, I populated the selections table with 50,000 x 25 records,
>> simulating 25 machines having records in the table. I created a view,
>> joining the two tables on the back end, and linked the view (with the
>> machine name as a field) to the front end. Using that 1,250,000 record
>> view with a parameter to only return the 50,000 records that match the
>> machine name, the form took about 17 seconds to open.
>>
>> One of the reasons to move the selections table to the back end was for
>> speed in opening the form. But the resulting 1.25 mil record table is
>> slowing things down than the smaller table in the front end did, even
>> with a heterogeneous join.
>>
>> Thus, I'm left with no solution, unless I can use a smaller table, of if
>> there's something I haven't seen re. using the view in Access (which I
>> don't think there is).
>>
>> Neil
>>
>>
>>
>> "Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
>> news:Xns96FF7327EABEYazorman@.127.0.0.1...
>>> Neil (nospam@.nospam.net) writes:
>>>> OK, point well taken. I don't see any workaround, though, since I'm
>>>> using ODBC linked tables. I can't use a pass-through query and pass the
>>>> table name as a parameter, because pass-throughs return read-only sets.
>>>> And a view wouldn't be able to return just the records for that
>>>> machine.
>>>
>>> As for how to sort out the linked tables, you will have to ask in an
>>> Access newsgroup.
>>>
>>>> Here's an idea. What if there were one table, but a series of views,
>>>> with
>>>> each view returning records for a particular unique ID. When the app is
>>>> opened, it's assigned an available ID and its link is set to the view
>>>> that
>>>> returns records for that ID. Still kind of a kludge, but perhaps a
>>>> little
>>>> better.
>>>
>>> A table-valued function with the machine name as parameter would be
>>> better.
>>> But without knowing Access, I'm quite sure that this can be solved by
>>> adding the machine name on the Access side as well. After all, that is
>>> also an RDBMS, and should be fitted for relational solutions.
>>>
>>>
>>>
>>> --
>>> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
>>>
>>> Books Online for SQL Server SP3 at
>>> http://www.microsoft.com/sql/techin.../2000/books.asp
>>>
>>
>>|||Both table have PKs; and the join is on the PKs (the main table has a
single-field PK; and the selections table has two field -- the corresponding
ID value from the main table combined with the machine name).

The 13 second form open time (with the 50k record selections table in the
front end joined heterogeneously with the 50k record main table in the back
end) is over a WAN. The LAN users get much better performance.

I tried a solution with *no* selection table (tracking selections in code,
since they don't need to remain past the current session), and it cut it
down to about 6 seconds. But, unfortunately, I ran into another issue with
that (currently discussing that in comp.databases.ms-access, "Trapping Click
With Calculated Check Box" thread). So if I can remove the selections table
altogether, that would be better. But, if I need to keep it, as noted
elsewhere in this thread, overall I get better performance with the huge
selections table (for all users) in the back end, rather than a small
selections table (for single user) in the front end. But the load time is
longer, and the load time is the thing that users have been complaining
about the most.

Thus, it would be great if I could bring down the load time while still
having the selections table in the back end. But I don't see what else I can
do to improve performance.

Thanks,

Neil

"Steve Jorgensen" <nospam@.nospam.nospam> wrote in message
news:scb9m1dva2tpb5j3r7sb3r0n51fv8f5eed@.4ax.com...
> On Sun, 30 Oct 2005 01:03:04 GMT, "Neil" <nospam@.nospam.net> wrote:
>>Yes, it can be done on the Access side, but, as noted, things are slowed
>>down. When I had a main SQL table (50,000 records) joined to a local
>>Access
>>table (also 50,000 records, with an index and a boolean field), the form
>>took about 13 seconds to open (with the join being, of course, in the
>>front
>>end).
> You really need to read up on the performance issues of using Access as a
> front-end to SQL Server. There are a few basic rules to know, (such as
> making
> sure join fields are indexed, and every table has a primary key) but if
> you
> follow them all, you should not have the performance issues you are
> describing.
> I routinely just build plain ol' Access queries that use criteria and join
> muliple linked tables together. JET is smart enough to build prepared
> statements and process the joins at the server side, so performance is
> pretty
> good.|||> You may be able to simplify things with the HOST_NAME function in your
> view.

Had strange results with using HOST_NAME. I added "=HOST_NAME()" to the
criteria column of the view's MachineName field. The view worked fine.
Similarly, if I open the view using a pass-through query in the front end,
it opens fine. But if I link the view to the front end, it opens with
"#Deleted" showing in each field (that's what Access displays when records
in a recordset have been deleted, but the recordset hasn't been requeried).

If, on the other hand, I hard-code the machine name into the view, then it
opens fine when linked to the front end. But something about the HOST_NAME
function that's causing it to not be able to get the records (or it gets the
records and then loses them).

Neil|||Neil (nospam@.nospam.net) writes:
> Had strange results with using HOST_NAME. I added "=HOST_NAME()" to the
> criteria column of the view's MachineName field. The view worked fine.
> Similarly, if I open the view using a pass-through query in the front
> end, it opens fine. But if I link the view to the front end, it opens
> with "#Deleted" showing in each field (that's what Access displays when
> records in a recordset have been deleted, but the recordset hasn't been
> requeried).
> If, on the other hand, I hard-code the machine name into the view, then
> it opens fine when linked to the front end. But something about the
> HOST_NAME function that's causing it to not be able to get the records
> (or it gets the records and then loses them).

Not sure I understand this (I still haven't learn Access :-), but there
is a gotcha here: which datatype is MachineName? I should be nvarchar
to avoid implicit conversions that precludes use of indexes. Not that I
can see that this explains behaviour you see above.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||On Sun, 30 Oct 2005 16:59:45 GMT, "Neil" <nospam@.nospam.net> wrote:

>Both table have PKs; and the join is on the PKs (the main table has a
>single-field PK; and the selections table has two field -- the corresponding
>ID value from the main table combined with the machine name).
>The 13 second form open time (with the 50k record selections table in the
>front end joined heterogeneously with the 50k record main table in the back
>end) is over a WAN. The LAN users get much better performance.

How many records are being returned to the form, and what kind of recordset
are you using? Is any of your links to a view? If linking to a view, did you
select a logical primary key when you created the link?|||"Steve Jorgensen" <nospam@.nospam.nospam> wrote in message
news:um7am1p16ht249oqhnb700uv2qg2007go4@.4ax.com...
> On Sun, 30 Oct 2005 16:59:45 GMT, "Neil" <nospam@.nospam.net> wrote:
>>Both table have PKs; and the join is on the PKs (the main table has a
>>single-field PK; and the selections table has two field -- the
>>corresponding
>>ID value from the main table combined with the machine name).
>>
>>The 13 second form open time (with the 50k record selections table in the
>>front end joined heterogeneously with the 50k record main table in the
>>back
>>end) is over a WAN. The LAN users get much better performance.
> How many records are being returned to the form, and what kind of
> recordset
> are you using? Is any of your links to a view? If linking to a view, did
> you
> select a logical primary key when you created the link?

50,000; dynaset; yes, the two tables are combined in the back end using a
view; yes.

But regarding the slowness issue, I think it's resolved. See my other post
in this thread. Thanks.

Neil|||Erland and everyone else who has been helping me here with this.

First, I want to thank you for steering me in the right direction. My
original idea about creating a series of tables was somewhat hair-brained;
but I was feeling desperate at the time and was willing to try anything.

Moving the table to the back end and making it a true relational table was
the right way to go. I noted that using this approach (with a resulting 1.25
mil record view) was actually slower than the original configuration with
the heterogeneous join. However, I opened the view, moved to the last
record, and now it's fast! So it seems that the indexes hadn't been filled
(or something like that). The form now opens in about 7 seconds (down from
13), which should be OK.

So I'm wondering if there is some command that one can use to accomplish
what I accomplished by moving to the last record.

Also, the other issue I recently noted regarding the HOST_NAME function is
still outstanding, and I should try to resolve it, as I've seen better
performance when using that than when passing the host name from the front
end. I started a new thread to discuss that, entitled, "Problem with
HOST_NAME Function with Linked View." If any of you would care to contribute
there, that would be great.

Thanks again to everyone for your help! It's much appreciated!!!

Neil

"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns96FF73E7D7719Yazorman@.127.0.0.1...
> Neil (nospam@.nospam.net) writes:
>> Yes, it can be done on the Access side, but, as noted, things are slowed
>> down. When I had a main SQL table (50,000 records) joined to a local
>> Access table (also 50,000 records, with an index and a boolean field),
>> the form took about 13 seconds to open (with the join being, of course,
>> in the front end).
>>
>> With the new solution, the main SQL table still has 50,000 records, but,
>> as a sample, I populated the selections table with 50,000 x 25 records,
>> simulating 25 machines having records in the table. I created a view,
>> joining the two tables on the back end, and linked the view (with the
>> machine name as a field) to the front end. Using that 1,250,000 record
>> view with a parameter to only return the 50,000 records that match the
>> machine name, the form took about 17 seconds to open.
>>
>> One of the reasons to move the selections table to the back end was for
>> speed in opening the form. But the resulting 1.25 mil record table is
>> slowing things down than the smaller table in the front end did, even
>> with a heterogeneous join.
>>
>> Thus, I'm left with no solution, unless I can use a smaller table, of if
>> there's something I haven't seen re. using the view in Access (which I
>> don't think there is).
> You will have to bear with me, since my knowledge of Access is so poor.
> But if I understand this correctly, you have a local table in Access
> with selections that typically has 50000 rows. And since each user
> has his own Access instance, this means that today there are some 25-50
> instances of this table.
> 13 seconds to open a form is indeed a long time, and many users would
> say a too long time.
> But moving this data to SQL server may not a very good idea at all.
> Sending
> 50000 rows over the wire is not done snap. On a local network it may be
> decently fast, but if you have a user that works from home, it will be
> a pain.
> So I would suggest that you should rather look into to load fewer rows
> into the form initially, and then fetch depending on what action the
> user takes. I can't believe that the user is looking at all 50000 at
> a time.
> If this data is only related to the user's selection, it's probably a
> good idea to keep it local anyway. The only point I can see with moving
> it to the server, is that it could permit the user to get back his
> selection if he moves to another machine.
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp|||I'm using varchar. Don't think that should make a difference, especially
since the view seems to work fine otherwise. But, anyway, I'll try nvarchar
and will let you know if it makes a difference.

If you reply to this, please reply in the "Problem with HOST_NAME Function
with Linked View" as noted in my other message. Thanks! And thanks again for
your help!

Neil

"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns96FFBFF7AC668Yazorman@.127.0.0.1...
> Neil (nospam@.nospam.net) writes:
>> Had strange results with using HOST_NAME. I added "=HOST_NAME()" to the
>> criteria column of the view's MachineName field. The view worked fine.
>> Similarly, if I open the view using a pass-through query in the front
>> end, it opens fine. But if I link the view to the front end, it opens
>> with "#Deleted" showing in each field (that's what Access displays when
>> records in a recordset have been deleted, but the recordset hasn't been
>> requeried).
>>
>> If, on the other hand, I hard-code the machine name into the view, then
>> it opens fine when linked to the front end. But something about the
>> HOST_NAME function that's causing it to not be able to get the records
>> (or it gets the records and then loses them).
> Not sure I understand this (I still haven't learn Access :-), but there
> is a gotcha here: which datatype is MachineName? I should be nvarchar
> to avoid implicit conversions that precludes use of indexes. Not that I
> can see that this explains behaviour you see above.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp|||On Sun, 30 Oct 2005 20:33:30 GMT, "Neil" <nospam@.nospam.net> wrote:

>"Steve Jorgensen" <nospam@.nospam.nospam> wrote in message
>news:um7am1p16ht249oqhnb700uv2qg2007go4@.4ax.com...
>> On Sun, 30 Oct 2005 16:59:45 GMT, "Neil" <nospam@.nospam.net> wrote:
>>
>>>Both table have PKs; and the join is on the PKs (the main table has a
>>>single-field PK; and the selections table has two field -- the
>>>corresponding
>>>ID value from the main table combined with the machine name).
>>>
>>>The 13 second form open time (with the 50k record selections table in the
>>>front end joined heterogeneously with the 50k record main table in the
>>>back
>>>end) is over a WAN. The LAN users get much better performance.
>>
>> How many records are being returned to the form, and what kind of
>> recordset
>> are you using? Is any of your links to a view? If linking to a view, did
>> you
>> select a logical primary key when you created the link?
>>
>50,000; dynaset; yes, the two tables are combined in the back end using a
>view; yes.

You're returning 50,000 rows to a form! No - that's not how client/server
works. You give users an interface that lets them pick what reasonable subset
or roll-up of the data they want to see, then navigate or drill-down form
there.

The point of SQL Server is that searching and filtering happens on the server
side and small result sets are returned to the client as requested.

>But regarding the slowness issue, I think it's resolved. See my other post
>in this thread. Thanks.

Solved? Perhaps, with a single user at a time, and no competing traffic on
the network. A design that returns 50,000 rows to a client in one result set
is findamentally flawed.|||Neil (nospam@.nospam.net) writes:
> Moving the table to the back end and making it a true relational table
> was the right way to go. I noted that using this approach (with a
> resulting 1.25 mil record view) was actually slower than the original
> configuration with the heterogeneous join. However, I opened the view,
> moved to the last record, and now it's fast! So it seems that the
> indexes hadn't been filled (or something like that). The form now opens
> in about 7 seconds (down from 13), which should be OK.
> So I'm wondering if there is some command that one can use to accomplish
> what I accomplished by moving to the last record.

Well, I still don't know Access, so I have still problems understanding
this.

There is no last record in a view. A view, just like a table is unordered.
But if you moved to what is the last record in what Access presents to
you, it is likely that all rows in the view went into the cache on SQL
Server. (Or a cache on the Access side if there is one.) One way to
force the view into cache is to run a query like "SELECT (DISTINCT col) FROM
view", and make sure to pick a column without index. Then again, as
users accesses the data it will make into cache. Pages that are not
referenced will be removed from cache, if the cache fills up. All that is
beyond your control. (OK, so there is PINTABLE, but don't use it.)

Since I don't know your application, nor do I know Access, I cannot really
suggest alternatives to the application design, but it just does not sound
right to me to get 50000 rows, before the users can start working.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Erland Sommarskog wrote:
> Neil (nospam@.nospam.net) writes:
<<>>
> > So I'm wondering if there is some command that one can use to accomplish
> > what I accomplished by moving to the last record.
> Well, I still don't know Access, so I have still problems understanding
> this.
> There is no last record in a view. A view, just like a table is unordered.
> But if you moved to what is the last record in what Access presents to
<<>>
> Since I don't know your application, nor do I know Access, I cannot really
> suggest alternatives to the application design, but it just does not sound
> right to me to get 50000 rows, before the users can start working.

Indeed.

I do know access pretty well. You could change the ODBC settings and
perhaps improve performance a bit. That's just propagating the
underlying problem though, IMO.

I've seen users who are experienced with excel presented with Access
solutions are direct conversions. These were a right mess. In every
case working with users analysing how they used the data resulted in
more practical systems designs.
It seems likely that similar redesign could be done in this instance.
Nobody really just looks through 50,000 records. By the time you page
through it all you'd need an eidetic memory to understand anything
across 50,000 records. What users will do is look at the top 20 on
price, sales or bottom 20 sales...longest outstanding invoices and
stuff like that.
Providing user selected sort criteria and top/bottom n selection
criteria is often the simplest approach.

>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp|||Just to add to the other responses saying some of the same. You have
the wrong approach. The functionality to filter, sort, etc should go in
the database not at the client. There is probably no point using SQL
Server at all if you just want to return the entire set of data and
manipulate it client side. I too have seen projects that failed
entirely because of such a totally naive approach to client-server
design.

--
David Portas
SQL Server MVP
--|||Thanks for your input. There are some issues with how users are currently
using some of the built-in Access tools that make it difficult to implement
some of these ideas, though I agree they would be good. I'll respond to your
comments and the similar ones by others shortly, when I have some time to
explain the situation more.

In the meantime, I was wondering about what ODBC settings you've had success
with in the past that improved performance. That would be helpful.

Thanks,

Neil

"andy" <aon14@.lycos.co.uk> wrote in message
news:1130755321.737337.245920@.g47g2000cwa.googlegr oups.com...
> Erland Sommarskog wrote:
>> Neil (nospam@.nospam.net) writes:
> <<>>
>> > So I'm wondering if there is some command that one can use to
>> > accomplish
>> > what I accomplished by moving to the last record.
>>
>> Well, I still don't know Access, so I have still problems understanding
>> this.
>>
>> There is no last record in a view. A view, just like a table is
>> unordered.
>> But if you moved to what is the last record in what Access presents to
> <<>>
>> Since I don't know your application, nor do I know Access, I cannot
>> really
>> suggest alternatives to the application design, but it just does not
>> sound
>> right to me to get 50000 rows, before the users can start working.
> Indeed.
> I do know access pretty well. You could change the ODBC settings and
> perhaps improve performance a bit. That's just propagating the
> underlying problem though, IMO.
> I've seen users who are experienced with excel presented with Access
> solutions are direct conversions. These were a right mess. In every
> case working with users analysing how they used the data resulted in
> more practical systems designs.
> It seems likely that similar redesign could be done in this instance.
> Nobody really just looks through 50,000 records. By the time you page
> through it all you'd need an eidetic memory to understand anything
> across 50,000 records. What users will do is look at the top 20 on
> price, sales or bottom 20 sales...longest outstanding invoices and
> stuff like that.
> Providing user selected sort criteria and top/bottom n selection
> criteria is often the simplest approach.
>
>>
>>
>> --
>> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
>>
>> Books Online for SQL Server SP3 at
>> http://www.microsoft.com/sql/techin.../2000/books.asp|||>> At least Neil knows how to
.. <<

What was I thinking?? Of course 2 + 2 = 5 if you are formally polite.

Yes, I am angry. I vounteer for a lot of non-profits. It is sooooo
nice that if behave properly and politely. the idiots will not kill
people. Where did a sense of professionalism get overridened by
behaving properly and politely -- whatever that means.|||--CELKO-- (jcelko212@.earthlink.net) writes:
>>> At least Neil knows how to
> . <<
> What was I thinking?? Of course 2 + 2 = 5 if you are formally polite.
> Yes, I am angry. I vounteer for a lot of non-profits. It is sooooo
> nice that if behave properly and politely. the idiots will not kill
> people. Where did a sense of professionalism get overridened by
> behaving properly and politely -- whatever that means.

Talking about going back to basics, before you start to tell people to
learn RDBMS and all that, how about learning grammar, to spell and
how to punctuate? :-)

Anwyay, behaving properly and politely is certainly very much of being
professional. Again, let's back to basics before you can start talking
about RDBMS...

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||With complex access2 apps I used to increase buffer size. As you're
pulling a shed load of data at a time that could well speed things up a
bit. Never tried it but maybe increasing threads would also help.

I would think replacing the way the users are using built in access
tools with functionality in a front end designed to reduce the amount
of data pulled is your best bet. This can of course be tricky as you'd
have to justify work and re-educate people.

The way it works at the moment sounds like you may as well just dump
the database out of sql server to an access copy overnight then the
user just copies this across and works off their C drive.|||"andy" <aon14@.lycos.co.uk> wrote in message
news:1130843576.597061.179990@.g49g2000cwa.googlegr oups.com...
> With complex access2 apps I used to increase buffer size. As you're
> pulling a shed load of data at a time that could well speed things up a
> bit. Never tried it but maybe increasing threads would also help.

Sounds like it's worth a try. But there's no way to change it with linked
tables, only with recordsets in code, right?

> I would think replacing the way the users are using built in access
> tools with functionality in a front end designed to reduce the amount
> of data pulled is your best bet. This can of course be tricky as you'd
> have to justify work and re-educate people.

I've been throwing around some ideas in my head, and I think we might be
able to do something like that. I think with enough explaining about how it
would work, I might be able to get the users on-board, especially when they
see the performance gains.

> The way it works at the moment sounds like you may as well just dump
> the database out of sql server to an access copy overnight then the
> user just copies this across and works off their C drive.

No can do. The users are editing as well as viewing. Users need to be able
to edit as well as view data, and see current changes in real-time.

Plus, the database is more than just this one form that brings up all
records in the recordset. There are many reports, functions, and so forth,
all of which use back-end objects or pass-throughs. It's just in this one
area (and primarily because of the way they use Datasheet View) that things
are less than optimum.

Neil