开发者

vbscript/sql adding a column to an insert statement

I am trying to add an additional column and value to an existing insert query -开发者_StackOverflow中文版 both integers, and running into trouble.

Anything to look out for?


you don't give much to go in in your question:

I am trying to add an additional column and value to an existing insert query - both integers, and running into trouble.

Anything to look out for?

it is best practice to list all columns you intend to include values for in the list of columns, so make sure you add them there, as well as the VALUES list:

insert into YourTable (col1, col2,..., newCol1, newCol2) 
VALUES (1,2,...,new1, new2)

make sure the you get the column names spelled correct and that the table actually has those new columns in it.


make sure the column name sequence is the same as your insert data sequence. Example

INSERT INTO TABLENAME (ColumnName1,ColumnName2) VALUES (1,'data')

Becomes

INSERT INTO TABLENAME (ColumnName1,ColumnName2,ColumnNameNEW) VALUES (1,'data','newcolumndata')

Notice both the new column name and the new data are in the third position in the sequence.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜