Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger - Insert into table With AutoGen ID

Status
Not open for further replies.

obryant32

IS-IT--Management
Feb 20, 2003
66
US
OK,

I have a trigger that doesn't seem to work. I'm assuming it's because the table I'm trying to insert into a table called LEADS that has a Field called "LeadID" which has a datatype of "bigint". The thing is that I'm not sure how to insert the rest of the data and have the LEADS table automatically assign a LEADID.

Any thoughts?

Thanks
Matt
 
Make the LeadID an identity field.

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
The thing is that I'm not sure how to insert the rest of the data and have the LEADS table automatically assign a LEADID.
Do you get an error?
I assume you mean LeadID is an identity column.
If so then you would Insert like this:
Code:
Insert Into Leads(col1,col2, ..etc..)
Values(Value1,value2..etc...)
What you have to do is specify the columns but not the identity column, since it will be automaticall generated.

Jim
 
Jim,

That's what I tried doing but it doesn't end up in the LEADS table. Also, I don't get any errors. Is there a way I can check for errors?

Thanks
Matt
 
Also, I don't have a value to enter for the leadid. I want the leads table, the table which the trigger is inserting into, to assign the leadid. How do I accomplish that?

Anyone?

Matt
 
MAke leadID an identity field. Then use the insert format specified by Jim in the trigger. If that still doesn;t do what you want, then post your code here and we can help you see what the problem is.

Questions about posting. See faq183-874
Click here to help with Hurricane Relief
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top