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 |
|
a.ashabi
Posting Yak Master
117 Posts |
Posted - 2008-04-29 : 13:17:48
|
| Hi.this is my query: INSERT INTO tbl_vendor (vendor_id ,vendor_name ,vendor_abbrv ) VALUES ( '', '#ucase(form.vendoreName)#' ,'#form.VendorAbbrv#' )bur the problem is I dont know when vendor_id is a primery key and should insert the automatic numbers.how should I write the query.thanks |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-29 : 13:21:57
|
| If vendor_id is an identity column, then you exclude it from the query to let SQL Server manage it:INSERT INTO tbl_vendor (vendor_name, vendor_abbrv)VALUES ('#ucase(form.vendoreName)#', '#form.VendorAbbrv#')Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-29 : 13:23:31
|
| Just define vendor_id to be of identity type and dont insert any value to it. On each insert it will generate automatically values.CREATE TABLE tbl_vendor(vendor_id int identity(1,1),....)then use:-INSERT INTO tbl_vendor (vendor_name,vendor_abbrv)VALUES ('#ucase(form.vendoreName)#','#form.VendorAbbrv#')Also make sure you check syntax for this in your version of sql (i dont think you're using MS SQL Server seeing the syntax) |
 |
|
|
|
|
|