say i have a table in my database which corresponds to a business object. in my application i create an instance of the business object class, say, CBusinessObject. Now I want to serialize this instance to the datastore. Is the best practice creating a stored procedure with an insert clause?
also, if i do my INSERT INTO inside a stored procedure, how do i automatically use the value of the next largest primary key? as an example:
if you are still working on this,
the right way as georgev suggests is to use a IDENTITY field in your table, which will automatically insert the next higher value in the column.
As far as the newid() goes, we can enter this value in a uniqueidentifier datatype column, for example: