Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
dupati1
Posting Yak Master
123 Posts |
Posted - 2003-09-26 : 09:59:09
|
Hi all,I am facing some problems while upsizing my current MS Access2000 database (.mdb file) to SQL server 2000 ( trying to make a client/server application by creating a .adp file).I did everything using Upsizing wizard available with the MS Access2000. During the Upsizing using wizard I selected the option to create a new database, connected to the SQL server out there on the network( made sure that connection was tested OK), exported all the tables( was not sure what attributes of the table to select, so i selected all the options-indexes, validation rules, defaults, table relationships using DRI and even added time stamps).Then i selected the option to create a new Access client/server application. I got two syntax errors while upsizing(one was while upsizing queries and the other was a form).But i clicked OK and the upsizing continued with no further errors. When i looked at the snapshot created by the wizard. All the tables were upsized properly,but none of the queries were upsized. I got errors like "The wizard was unable to analyze the SQL for this query" or "This query is not upsizeable because it depends on a Form parameter". There was no information regarding forms or reports on this snapshot.When i opened the .adp file created by the wizard, some of the components on the Forms were not working and giving the error messages like "The record source specified on this form or report does not exist".I am new to this field and I would appreciate if anybody suggest me something related to these problems. Thanks in advance.VJ |
|
JimL
SQL Slinging Yak Ranger
1537 Posts |
Posted - 2003-09-26 : 10:11:29
|
I have tried to do this many times unfortunatly I have Yet to get the wiz to convert a query correctly. This is most likely because it would have to decide weather to make it a view,Function or stored procidure. I had to Re-Write them all in SQL.Jims quick Rule of thumb Views = Simple data In/outFunctions = Complex data In/out a must for Variable filters.Stored Procidures = Update,Delete or Insert Hope this helpsCheck out BOL (Books On Line) for detailed information. JimUsers <> Logic |
 |
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2003-09-26 : 10:58:16
|
Agree with Jim in that the only thing I have consistently gotten to upsize from Access to SQL Server are tables.I prefer to use Stored Procedures for almost everything (selects, inserts, updates, deletes) because it keeps my access technique from an application consistent, and it's easy to pass in parameters. Plus all the other benefits of sprocs like performance and security. I hardly ever use views, but they can be handy for common admin/ad-hoc querying, or to solidify a complex set of joins that will be used frequently. I consider functions in SQL Server a specialty item to return me a value based on certain inputs, and are pretty darn handy in some SELECT statements.But back to the original question, I'd encourage you to dive in a review the SQL behind the Access queries and rewrite them in SQL Server. I don't believe that any wizard will produce code that is both efficient and easy to maintain.------------------------------------------------------The more you know, the more you know you don't know. |
 |
|
JimL
SQL Slinging Yak Ranger
1537 Posts |
Posted - 2003-09-26 : 11:43:39
|
Functions and views also let you set the level of access security I.E. Read only, Update, insert, delete, where a Stored procidure is wide open that is why I try to limit it to Actions.It is a good practace to control security at the SQL level rather than the application level.JimUsers <> Logic |
 |
|
dupati1
Posting Yak Master
123 Posts |
Posted - 2003-09-26 : 12:06:20
|
Thanks a lot guys. Thanks for your suggestions. i will review some related books and also follow the suggestions given by you people.But one other thing i would like to know is that, Is it comparatively easy to convert the old DB application to a front-end/back-end application rather than to make a client/server aplication, or will i face with any daunting problems again in the process of making it a front-end/back-end application-VJ |
 |
|
JimL
SQL Slinging Yak Ranger
1537 Posts |
Posted - 2003-09-26 : 12:27:51
|
Once you fix your Querries you will have most of your problems behind you. No matter how much work it takes to get there you will be much-much-much better off with a SQL backend.Howerver once you learn more SQL I would advise moving as much of the application front end into stored procidures in the back end as you can.You will understand this better as you learn a little more.You have already discovered one of the best tools you can have, THIS SITE!I have learned more from reading and submitting to this site than the books I bought (hundreds of dollars Worth).JimUsers <> Logic |
 |
|
dupati1
Posting Yak Master
123 Posts |
Posted - 2003-09-30 : 15:18:44
|
Thanks Jim,I have been doing modifications to the code and tried to change some queries manually but got some errors. The below are two queries from my access db application. I would be thankful if you could provide me the details of what changes i should make and any other syntax differences that i should be aware of. I inserted dbo. in front of the data source..like.... UPDATE dbo.[OR Record] ....(Here OR Record is the name of the table, and all the others like Anesthesia stop time, anesthetist, Percert Code etc are the column names)to make it work in SQL Server, but still got errors.The below are two access queries 1. Anesth start stop update queryUPDATE [OR Record] SET [OR Record].[Anesthesia stop time] = Null, [OR Record].[Anesthesia start time] = NullWHERE ((([OR Record].[Anesthesia stop time]) Is Not Null) AND (([OR Record].[Anesthesia start time]) Is Not Null) AND (([OR Record].Anesthetist)="None"));2. Billing QuerySELECT [OR Record].[Date of Surgery], [OR Record].[Name of Surgeon], [OR Record].Procedure, [OR Record].Anesthetist, [last Name] & "," & " " & [First name] AS Expr1, [OR Record].[Procedure 2], [OR Record].[Surgeon 2], [OR Record].[Precert Code], [OR Record].[Date of Birth], [OR Record].[Type of anesthesia], [OR Record].[In patient], [OR Record].[Surg Code], [OR Record].[ASA Code], [OR Record].[Medically directed by Anesth]FROM [OR Record]WHERE ((([OR Record].[Date of Surgery])>=[Forms]![Billing query start and stop dates].[Starting date] And ([OR Record].[Date of Surgery])<=[Forms]![Billing query start and stop dates].[Stopping date]))ORDER BY [OR Record].[Date of Surgery];please help me with these queries so that i can work on other queries and I have no idea about how to import the forms. Thanks in advance.VJ |
 |
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-09-30 : 16:09:31
|
Just an aside, and maybe a different approach...If you find converting to be a daunting task, take the path of least resistance...I had waaaaayyyyyy to many objects to change...I linked all of the SQL Server tables..They all linked like: dbo_myTableI then wrote code that generated "alias" queries. They had the same name as the original tables...same thing with the column names...The alias queries are simply a SELECT cols,...FROM dbo_myTableThe entire app should work now (after they're created) with little to no changes to the code...One caveat...the forms where written so poorly that some of the crawled...If you have many controls that are bound to a form...you'll establish a connection per...2 if they are updateable...Also there's the wonderful access habit of nesting queries...had 1 once with 13 levels and 4 branches...WHAT FUN...Anyway...here's the code to generate the alias queries...maybe it'll help...As for me, the app was soooooooooooooooobad (did I say that already?) that we rewrote it with SQL Server and JAVA browser based...Sub createAliasQueries() Dim wks As Workspace Dim db As Database Dim dbMe As Database Dim rs As Recordset Dim tdf As TableDef Dim qdf As QueryDef Dim myfield As Field Dim intResponse As Integer Dim strDBPath As String Dim strField As String Dim strSQL As String Dim strSQLTableName As String Dim strSQLColumnName As String Dim strdbName As String strdbName = "TaxMgmtDB.mdb" strDBPath = "\\NJEROCF04\ESolutions\Technology Services\Projects\Tax Compliance\Databases\AccessProd\" & strdbName strField = Chr(13) strSQL = "SELECT " Set wks = DBEngine.CreateWorkspace("temp", "sysadmin", "") Set db = wks.OpenDatabase(strDBPath) Set dbMe = CurrentDb db.TableDefs.Refresh MsgBox "Number of TableDefs: " & db.TableDefs.Count 'Loop trhough all the TableDefs in the database For Each tdf In db.TableDefs 'Ignores system tables, which begin with "MSys" prefix If InStr(tdf.Name, "MSys") = 0 Then strSQLTableName = tdf.Name 'Look for table names with zero first character (not allowed in SQL Server) If Left(strSQLTableName, 1) = "0" Then strSQLTableName = "Z" & strSQLTableName End If 'Look for tables names with spaces (not allowed in SQL Server) While InStr(strSQLTableName, " ") > 0 Mid(strSQLTableName, InStr(strSQLTableName, " "), 1) = "_" Wend Set qdf = dbMe.QueryDefs("qrySQLServerTableColumns") qdf![parTableName] = strSQLTableName Set rs = qdf.OpenRecordset 'Skips any table names not contained in the lookup table If rs.RecordCount > 0 Then rs.MoveFirst 'Loop through all the fields in the TableDef and add them to the message and SQL strings For Each myfield In tdf.Fields strSQLColumnName = rs![FieldName] strField = strField & Chr(13) & myfield.OrdinalPosition & " " & myfield.Name 'JR If strSQLColumnName = myfield.Name Then strSQL = strSQL & "[" & strSQLColumnName & "] , " & Chr(13) Else strSQL = strSQL & "[" & strSQLColumnName & "] AS [" & myfield.Name & "] , " & Chr(13) End If rs.MoveNext Next 'Chop the last comma and space off the sql statement, then add a space before the "FROM" clause strSQL = Left(strSQL, Len(strSQL) - 3) & " " & Chr(13) 'Complete the SQL statement strSQL = strSQL & "FROM [dbo_" & strSQLTableName & "]" ' intResponse = MsgBox(tdf.Name & " will be converted to a query named z_" & tdf.Name & "." & Chr(13) & _ ' "If the SQL statement below appears correct, click 'Yes.'" & Chr(13) & _ ' "If not, click 'No' and the query will be named zBAD_" & tdf.Name & "." & _ ' Chr(13) & Chr(13) & strSQL, vbYesNo) ' If intResponse = vbYes Then 'Create a new query to replace the table 'JR Set qdf = dbMe.CreateQueryDef(tdf.Name, strSQL) 'Set qdf = db.CreateQueryDef("z_" & tdf.Name, strSQL) ' Else 'Create a new query to replace the table, but name it differently so user knows to edit the query ' Set qdf = dbMe.CreateQueryDef("zBAD_" & tdf.Name, strSQL) ' End If End If 'Reset the two strings strField = "" & Chr(13) strSQL = "SELECT " End If Next MsgBox "Done." rs.Close qdf.Close dbMe.Close db.Close wks.CloseEnd Sub Brett8-)SELECT @@POST FROM Brain ORDER BY NewId()That's correct! It's an AlphaNumeric! |
 |
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2003-09-30 : 19:43:45
|
Dupati, a quick tip when converting queries to SQL Server, I would suggest getting rid of all the parentheses in the where clause and then only putting in ones you need to actually control the comparisons such as to control where ORs and ANDs are occurring. Access seems to have some love affair with parentheses in its queries and SQL Server does not. Once you've gotten rid of the ones you don't need then fixing the query should be simpler.------------------------------------------------------The more you know, the more you know you don't know. |
 |
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-10-01 : 11:24:18
|
I bet you'll still have problems..even with something as simple as:UPDATE [OR Record] SET [OR Record].[Anesthesia stop time] = Null , [OR Record].[Anesthesia start time] = Null WHERE [OR Record].[Anesthesia stop time] Is Not Null AND [OR Record].[Anesthesia start time] Is Not Null AND [OR Record].Anesthetist = "None"; How did you create the tables in SQL Server? if you linked them to Access dod you rename them? Or are the linked as dbo_[OR Record]Spaces in table and column names are not good either. Did the change to underbars in SQL Server when using the wizard?Can you post the DDL for this table from SQL Server?Did you try my approach above? Do it manually for 1 table and check it out...Brett8-)SELECT @@POST FROM Brain ORDER BY NewId()That's correct! It's an AlphaNumeric! |
 |
|
dupati1
Posting Yak Master
123 Posts |
Posted - 2003-10-01 : 12:05:11
|
Hi Brett,Thanks for your suggestions and for your time. I am still working on it. I will post as soon as I proceed any further.ThanksVijay |
 |
|
JimL
SQL Slinging Yak Ranger
1537 Posts |
Posted - 2003-10-01 : 13:50:44
|
One other point is naming. Both table and field names. I would fix this now, it will be less problems in the long run and you will no longer use [ ]Some Higher functions of SQL do Not like spaces in names.(I found this out the hard way when I tried to run a redundent server and spent 2 months fixing names in forms querys and reports.)For example [OR Record].[Anesthesia stop time] OR Record table... Change to OR_Record ... or possibly OrRecordAnesthesia stop time... Change to Anesthesia_stop_time ... Or possibly AnesthesiaStopTimeThen your entry would look like this.dbo.OR_Record.Anesthesia_stop_timeAlso do not use " around a text use ' So lets take your first Query as a stored procidureCREATE PROCEDURE dbo.Anesth_start_stop_update_queryASUPDATE dbo.OR_RecordSET Anesthesia_stop_time = Null, Anesthesia_start_time = NullWHERE (Anesthesia_stop_time Is Not Null) AND (Anesthesia_start_time Is Not Null) AND (Anesthetist = 'None')Sorry it took so long to get back to you. Does this help?JimUsers <> Logic |
 |
|
|
|
|
|
|