The below-mentioned are the Oracle SQL queries to generate the Sequence ID. Can anyone please help in rewriting the same queries compatible with MS SQL, to produce the same result?
DB Sequence: -
create sequence my_sequence start with 1Create a function get_next_code that will use the sequence and return the incremented value (as string): -
create or replace function get_next_code return varchar2 as code number; begin select my_sequence.nextval into code from dual; return to_char(code); end;Create a view which will pass the incremented value: -
create or replace view my_counter (my_code) as (select get_next_code() from dual);
Query used to get the sequence ID generated(This is the query used in the java program):
select my_code from my_counter
Expecting the same result in MS SQL
Need the steps to create an MSSQL View/Table with only one column and one row that generates a Sequence ID, when I run a select query every time.
In SQL Server you create sequences in a similar way.
Then to get the next value
You can also use
sp_sequence_get_rangeto get a range of numbers.