Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

i am using sql server. i think i need to brush up on my db admin knowledge, cause i don't know what you really mean.

 

gives me a place to start my google search though. thanks :)

  • Moderators
Posted

Create a Stored Proc to do your inserts. Here's a sample you can run in Query Analyzer....

 

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO
CREATE		PROCEDURE dbo.Some_Stored_Proc 
	@Fname varchar(30)= null,-- not required
	@Lname varchar(30)--required
AS
declare @id int
SET @id = 0

if (@Lname != '')--ensures a valid input
BEGIN
Begin transaction
INSERT INTO	Table1 
		([Fname],[Lname],[date_created])
Values		(@Fname, @Lname,getdate())

SET @id =  @@IDENTITY
commit transaction

return @id --return the new ID number to the caller
END

SET QUOTED_IDENTIFIER OFF

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

Visit...Bassic Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...