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 - sql statement i want to get the maximum value in the group and the value in another column of the maximum value row
- i want to display the sql statement error of sql server on the net screen
- sql server - please tell me about exists in sql
- [sql server/vscode/ms-sql] about creating schema and adding tables
- sql server - i want to get the total of the values aggregated by sql
- sql server - i don't know how to prevent sql injection attacks
- about variable declaration in if statement from c++17
- php - about launching the server of codeigniter (mac)
- sql server - i have installed adobe creative cloud, but i am unable to install it with an error
- sql server - i want to successfully use the session id in implementing login authentication
- sql server - i want to know the whole flow when writing sql
- sqlite - about select statement (when adding a period to the search condition)
- about api server framework selection
- sql - when the sum is taken from the decimal point column saved as string and the table with insert overwrite, the total is diff
- sql server - i want to cancel the mirroring that consists of two db servers and use only one
- ruby - about an infinite loop in a while statement
- sql server - i can no longer log in to wordpress being built on my local server
- about windows server rds
- this is a question about changing the table format of standard sql
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- python - you may need to restart the kernel to use updated packages error
- python 3x - typeerror: 'method' object is not subscriptable
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- xcode - pod install [!] no `podfile 'found in the project directory
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- android studio - unresolved reference comes out in kotlin