In my sql server 12.0 I have created a sequence:
CREATE SEQUENCE [dbo].[SESSIONI_dv_seq] 
 AS [bigint]
 START WITH 1
 INCREMENT BY 1
 MINVALUE -9223372036854775808
 MAXVALUE 9223372036854775807
 CYCLE 
 CACHE; 
sql server management studio works perfectly:
select Next value for  dbo.SESSIONI_dv_seq 
return the correct value.
At this point, in a powershell script I want to obtain a new sequence value using invoke-sqlcmd
$DataSet = Invoke-Sqlcmd -Database "alglogistica" -Query "SELECT SESSIONI_dv_seq_value=next value for dbo.sessioni_dv_seq;" -ServerInstance  "10.81.104.185\SQL14"
This statement doesn't work (without no error returned by the script).
I have tried other selects in the query and these work perfectly.
 
     
    