i trying find minimum value of primary key column of type (int) in particular table
a portion of stored procedure code:
if not exists ( select * table ) begin select * table end else begin select min(columnone) table end
this main code after reading:
if (!reader.read()) return "empty table"; else return reader.getint32(0).tostring();
my executereader has no problem when got exception @ statement
reader.getint32(0).tostring()
i believe extract information wrongly when tables have more 1 entry. correct function should call reader number??
i didn't question. specify min() value in question , wrote max() function in t-sql script.
you can try below if want retrieve next val of column
select isnull(max(columnone),0)+1 table
above query return 1 in case table empty else max current value+1(next available value) table.
Comments
Post a Comment