In Microsoft SQL Server Management Studio 18
SELECT IDENT_CURRENT ('KEYWORD')
To get the current value of the IDENTITY column.
I want to get and store the current value of the IDENTITY column of another table in a table
INSERT INTO [dbo]. [IMAGEKEYWORD] (ImageID, Keyword) SELECT IDENT_CURRENT ('IMAGE', 'KEYWORD') // 'IMAGE' and 'KEYWORD' are in separate tables with IDENTITY column.
Msg 174, Level 15, State 1, Line 2 The ident_current function requires 1 argument (s).</Code></pre> <p><br /> Is displayed and you cannot continue.</p> <pre><code data-language = "SQLServer">INSERT INTO [dbo]. [IMAGEKEYWORD] (ImageID, Keyword) SELECT IDENT_CURRENT ('IMAGE') SELECT IDENT_CURRENT ('KEYWORD')
The select list for the INSERT statement contains fewer items than the insert list.
Msg 120, Level 15, State 1, Line 1 The number of SELECT values must match the number of INSERT columns.
Is displayed and cannot be executed.
Please tell me how I can do it.
Microsoft SQL Server Management Studio 18
I'm not searching because I don't know how to search.
Answer # 1
I think the error message is as it is.
There is also a web service that translates if you don't understand English.
Translated by Google.
The ident_current function requires 1 argument (s).
The ident_current function requires one argument.
The select list for the INSERT statement contains fewer items than the insert list.The number of SELECT values must match the number of INSERT columns.
The select list of the INSERT statement contains fewer items than the insert list. The number of SELECT values must match the number of INSERT columns.
Answer # 2
Get into the habit of checking the manual. INSERT ... SELECT syntax
Answer # 3
How about using SCOPE_IDENTITY ()?
The example query below is automatically generated by Visual Studio, but ProductID is the IDENTITY column.
INSERT INTO [Products] ([ProductName] ...) VALUES (@ProductName ...); SELECT ProductID, ProductName ... FROM Products WHERE (ProductID = SCOPE_IDENTITY ()) ";
- [sql server/vscode/ms-sql] about creating schema and adding tables
- sql server - sql statement i want to get the maximum value in the group and the value in another column of the maximum value row
- server - about netlify settings in muumuu domain
- java - about sql: (colon)
- sql server reporting services - about the parameters of the reporting service
- python - about programs that use the continue statement
- server - about the release of the site renewal
- sql server - i want to get the number of value matches between multiple columns in an sql statement
- sql - i can't connect to the db with sakura's rental server
- sql server - sqlserver 2019 (express) half-width/full-width conversion
- python - things to worry about in the for statement
- sql server - sql i want to extract data at a fixed time across days
- [sql server] is the database generated from the script the same as the database from which it was generated?
- sql server - active node and passive node what does signing in to the active node mean?
- sql - i want to find out what is causing the server to be overloaded from the query when the load is high
- sql server - i want to restore with the sql command
- sql server - extract commands to execute gui operations in sqlserve management studio
- about the return statement of processing (character string)