0

I have a problem with the SQL query- nextval in a SQL Server database:

The multi-part identifier "applicationauth.nextvalue" could not be bound.

Any idea what could be wrong?

Here is query:

insert into applicationauth (app, optionname, conditionnum, groupname, applicationauthid) 
    select 'AUTOSCRIPT', 'ATTRVAL', 'ATTRVALUECON', varvalue, applicationauth.nextvalue
    from maxvars 
    where varname = 'ALLUSERGROUP';

insert into applicationauth (app, optionname, conditionnum, groupname, applicationauthid) 
    select 'AUTOSCRIPT', 'HIDEATTR', 'HIDEATTRCON', varvalue, applicationauthseq.nextval

insert into applicationauth (app, optionname, conditionnum, groupname, applicationauthid) 
    select 'AUTOSCRIPT', 'ATTRVAL', 'ATTRVALUECON', varvalue, applicationauthseq.nextval
    from maxvars 
    where varname = 'ALLUSERGROUP';

insert into applicationauth (app, optionname, conditionnum, groupname, applicationauthid) 
    select 'AUTOSCRIPT', 'HIDEATTR','HIDEATTRCON', varvalue, applicationauthseq.nextval
    from maxvars 
    where varname = 'ALLUSERGROUP';

insert into applicationauth (app, optionname, conditionnum, groupname, applicationauthid) 
    select 'AUTOSCRIPT', 'HIDEBUT', 'HIDEBUTCON', varvalue, applicationauthseq.nextval
    from maxvars 
    where varname = 'ALLUSERGROUP';

insert into applicationauth (app, optionname, conditionnum, groupname, applicationauthid) 
    select 'AUTOSCRIPT', 'HIDEIMP', 'HIDEIMPCON', varvalue, applicationauthseq.nextval
    from maxvars 
    where varname = 'ALLUSERGROUP';

(and so on and so forth ...)

I'm getting following error message:

Msg 4104, Level 16, State 1, Line 2
The multi-part identifier "applicationauth.nextvalue" could not be bound.

Msg 4104, Level 16, State 1, Line 9
The multi-part identifier "applicationauthseq.nextval" could not be bound.

(.... and so on and so forth)

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    https://stackoverflow.com/help/mcve... Are all those similar INSERT statements really needed to reproduce the problem? – jarlh Jan 16 '19 at 14:34
  • What is the "applicationauth.nextvalue". Did you create sequence? – Zeki Gumus Jan 16 '19 at 14:37
  • 1
    There is no `nextval` anywhere in your table. Are you laboring under the misconception that there's a `NEXTVAL` function/method in T-SQL? There isn't. It would help if you could explain what you're actually trying to accomplish (table structure, input, desired output). What you want can probably be done with an identity column, a sequence or an application of `ROW_NUMBER()`, but as stated it's not clear how those would be used. – Jeroen Mostert Jan 16 '19 at 14:37

1 Answers1

3

Is this what you're looking for?

Replace applicationauthseq.nextval with NEXT VALUE FOR applicationauthseq.

Not sure where you got that initial syntax, but NEXT VALUE FOR is how you call a SEQUENCE object from T-SQL.

Eric Brandt
  • 7,886
  • 3
  • 18
  • 35