tags:

views:

40

answers:

2

I'm writing a database in Microsoft Access to save the client from having to buy SQL Server. How do you get the primary key of the row that I just inserted? In SQL Server, it's

INSERT INTO TABLE(FIELDLIST) VALUES(VALUELIST)
SELECT * FROM TABLE WHERE PrimaryKeyID = SCOPE_IDENTITY()
+4  A: 

Try:

SELECT @@Identity

jinsungy
A: 

If it's about money, get SQL Server Express; it's free.

If you are writing an application, you still need Microsoft Access, but you can attach a SQL Server Express database to your application, and use the SQL Server Express database as your storage medium.

If the application is to be multi-user, using SQL Server Express as your backend database from the outset will make the application more reliable, especially if you lack the specialized knowledge needed to create a multi-user application properly using Access as a backend.

Multi-user applications have two parts: the database and the application frontend. The database will reside on one machine, and will be shared by each application frontend. The application frontend will be copied to each user's computer.

If you are serious about Access development, get this book. Although it is dated, it is still the definitive work on Access development.

Robert Harvey
This is a good piece of advice. A lot of hosting companies provide 1 SQL Server database plus as many Microsoft Access databases as you need. I'm trying to limit the amount of tables I'm piling into my SQL Server database. I'll have to check to see if there are any hosting companies that provide SQL Server Express for free.
cf_PhillipSenn
Howe many tables are we talking about? Is the number of tables growing continuously? If not, your single SQL Server instance should be able to handle anything you throw at it. If the tables are growing continuously (are you adding a new table every day?), and the tables all have the same fields, consider adding another field to distinguish the table instances (a date field, perhaps?) and put all of the data into a single table.
Robert Harvey