473,394 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

SQL Server

I am working on a project where I will be selecting an n'th number of
records for 700 reps based on zip codes.

My question is the below sql statement worked on an access table...

sSQL = "Update OA Set OA.RepID = " & rsRep!RepID & " " _
& "Where OA.PrimaryID In (Select top " & lTempRequest & " " _
& "PrimaryID from OA where zip ='" & rsRep(sZipSelect) & "'" _
& "and RepID is null)"

but the above statment doesn't work against a link ODBC connection to
SQL server table. It executes but just hangs up.

I can issue the following statement in T-SQL on SQL server no problem.

update oa set repid = 2 where primaryid in (select top 5000 primaryid
from oa where zip = '30121' and repid is null)

This is basically the exact same command as the access query. Does
anyone know why one works and the other doesn't?

I have got a fix in place by using a stored procedure and calling that
through access. Probably a better way of doing it anyways...

Thanks...
Nov 13 '05 #1
4 1952
One issue is that ODBC is old technology, becoming outdated. There may
be other issues, based on your setup, but ODBC technology is one of the
bigger issues. ADO technology is much more reliable and way faster
because it has way more bandwidth than ODBC.

There are two kinds of ADO, com ADO and ADO.Net. For Access you would
use com ADO. For that you need to download Mdac2.5 and Mdac2.6.
Mdac2.5 contains Jet3.51 or 3.6 or something that you need for Jet.
Mdac2.6 is the upgraded version of 2.5 (more reliable). Mdac2.7+ I
believe is for .Net (maybe 2.8, but you don't need this for Access, but
definitely Mdac2.5 and 2.6).

ADO uses disconnected datasets where ODBC is a constant connection to
the datasource, thus ODBC has way lower bandwidth (it takes a lot of
resources to stay connected to the data continuously). With ADO, you
can invoke a sql server stored procedure, retrieve the data and then
close the connection. Here is a sample of ado for getting data from a
sql server sp - invoked from a standard module in an Access97 mdb:

Sub GetdataFromSqlSrv()
Dim cmd As New ADODB.Command, conn As New ADODB.Connection
Dim RSado As New ADODB.Recordset, RSdao As DAO.Recordset
Dim i As Long, j As Long, k As Integer, RetVal As Variant
Dim eDate As Date, sDate As Date, d as date
Dim sTim As Single, eTim As Single, totTim As Single

sTim = Timer
cmd.ActiveConnection="Provider=SQLOLEDB;Data Source=srv1;" _
& "Initial Catalog=myDB;UID=SA;PWD=abc;"
cmd.CommandTimeout = 600
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "stp_GetData"
d = #1/1/2004#
sDate = Month(d) & "/1/" & Year(d)
eDate = DateAdd("m", 1, sDate) - 1 'get one month of data
cmd.Parameters("@bDate").Value = sDate
cmd.Parameters("@eDate").Value = eDate
Set RSado = cmd.Execute
Set RSdao = CurrentDb.OpenRecordset("tbl1")
DoEvents
Do While Not RSado.EOF
RSdao.AddNew
For i = 0 To RSado.Fields.Count - 1
RSdao(i) = RSado(i) 'copy data from each field
Next
RSdao.Update 'update dao recordset
RSado.MoveNext
Loop
cmd.ActiveConnection.Close 'close ado connection
eTim = Timer
totTim = eTim - sTim
totTim = (eTim - sTim) / 60 'get time in minutes
RetVal = SysCmd(acSysCmdSetStatus, "Total Time is " & totTim & " minutes
Or Total Time is " & totTim * 60 & " seconds")

End Sub
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #2
J Reed,
If you've got it working in T-SQL then leave it there. T-SQL rocks over VBA
& Jet.

"J Reed" <re*********@hotmail.com> wrote in message
news:42**************************@posting.google.c om...
I am working on a project where I will be selecting an n'th number of
records for 700 reps based on zip codes.

My question is the below sql statement worked on an access table...

sSQL = "Update OA Set OA.RepID = " & rsRep!RepID & " " _
& "Where OA.PrimaryID In (Select top " & lTempRequest & " " _
& "PrimaryID from OA where zip ='" & rsRep(sZipSelect) & "'" _
& "and RepID is null)"

but the above statment doesn't work against a link ODBC connection to
SQL server table. It executes but just hangs up.

I can issue the following statement in T-SQL on SQL server no problem.

update oa set repid = 2 where primaryid in (select top 5000 primaryid
from oa where zip = '30121' and repid is null)

This is basically the exact same command as the access query. Does
anyone know why one works and the other doesn't?

I have got a fix in place by using a stored procedure and calling that
through access. Probably a better way of doing it anyways...

Thanks...

Nov 13 '05 #3
J Reed wrote:
I am working on a project where I will be selecting an n'th number of
records for 700 reps based on zip codes.

My question is the below sql statement worked on an access table...

sSQL = "Update OA Set OA.RepID = " & rsRep!RepID & " " _
& "Where OA.PrimaryID In (Select top " & lTempRequest & " " _
& "PrimaryID from OA where zip ='" & rsRep(sZipSelect) & "'" _
& "and RepID is null)"

but the above statment doesn't work against a link ODBC connection to
SQL server table. It executes but just hangs up.

I can issue the following statement in T-SQL on SQL server no problem.

update oa set repid = 2 where primaryid in (select top 5000 primaryid
from oa where zip = '30121' and repid is null)

This is basically the exact same command as the access query. Does
anyone know why one works and the other doesn't?

I have got a fix in place by using a stored procedure and calling that
through access. Probably a better way of doing it anyways...

Thanks...


Use Profiler to trace the SQL being generated, in your original query
against the linked table you will probably see a stream of stored
procedures being prepared then executed, this is typically 1 pair of sp
calls per row in your database, maybe double if the selection goes like
that as well, throw in a join or two and with an infinate timeout it
will probably go on all day and night and some of the following morning.
Hell I bet it's even doing that select top 5000 for each row.

It highlights how inefficient it is to just simply link tables when
upsizing to SQL Server., only the simplest of queries will work well.
You should go ahead and do as you did and execute directly on the server.

BTW, in SQL Server, using "where exists()" is generally more efficient
than using "where in ()", the opposite of what is generally true for Jet
tables. Don't worry about using "exists(select * from...) notation, SQL
Server won't actually do a "select * from" and discard a bunch of
columns, it will translate it to "exists(select 1 from ...).

--

\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\

Nov 13 '05 #4
On 30 Sep 2004 21:19:59 GMT, Rich P <rp*****@aol.com> wrote:
One issue is that ODBC is old technology, becoming outdated. There may
be other issues, based on your setup, but ODBC technology is one of the
bigger issues. ADO technology is much more reliable and way faster
because it has way more bandwidth than ODBC.

(more which I have snipped)

Hi
Yes, all the db vendors take care to make their own native methods the
most efficient way of using their system. The last thing they want is
to make it too easy to move to another product.

This suits developers as well!

Or am I too cynical?

David

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Phil | last post by:
I am using a Pascal like language (Wealth-Lab) on W2K and call this server: class HelloWorld: _reg_clsid_ = "{4E797C6A-5969-402F-8101-9C95453CF8F6}" _reg_desc_ = "Python Test COM Server"...
6
by: Nathan Sokalski | last post by:
I want to set up SQL Server on Windows XP Pro so that I can use the database capabilities of ASP and IIS. I am probably using some incorrect settings, but I am not sure what they are. Here is what...
9
by: Grim Reaper | last post by:
My work let me put SQL Server 7.0 Enterprise Edition on my laptop. I have never setup a server from the beginning, so I am a little new at creating server groups. Alright, I am trying to create...
0
by: Chris Halcrow | last post by:
Hi I've spent ALL DAY trying to re-install SQL Server 2000 on Windows XP. I continually get the error 'cannot configure server' just at the end of the installation. I've tried the following: ...
0
by: Zorba.GR | last post by:
IBM DB2 Connect Enterprise Edition v8.2, other IBM DB2 (32 bit, 64 bit) (MULTiOS, Windows, Linux, Solaris), IBM iSoft Commerce Suite Server Enterprise v3.2.01, IBM Tivoli Storage Resource Manager...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
14
by: Developer | last post by:
Hello All, i have recently installed VS2005 and was trying to install SQL sever 2000. I have Win XP' SP2. But when I tried installing, it only installed client tools and not the database. Can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.