sql server - MSSQL error #120 -
i have following sql:
insert [dbo].[table1] ([col1],[col2],[col3],...[col14]) select * [dbo].table2 go
running throws mssql err #120 means number of columns line insert. table2 has 5 columns , table1 has 14. correct in assuming cause of error? reason ask a) not familiar mssql , b) unfamiliar database.
yes, cause of error.
you have to:
insert [dbo].[table1] ([col1],[col2],[col3],...[col14]) select col1, col2, col3, col4, col5, --your table's columns 'const1', null, 1, etc... --other values want other columns, [dbo].table2 --defaults, constants, null, etc. go
or
insert [dbo].[table1] ([col1],[col2],[col3],[col4],[col5]) --the rest have default value. select col1, col2, col3, col4, col5 [dbo].table2 go
Comments
Post a Comment