I found the solution🎉
When you import a .shp into the SQL Server database, the imported file does not come with an SRID (the projection is not defined). To fix this you need to specify manually the SRID code
After that, you need to create a table using this script:
CREATE TABLE GEOMETRY_COLUMNS(
F_TABLE_SCHEMA VARCHAR(30) NOT NULL,
F_TABLE_NAME VARCHAR(30) NOT NULL,
F_GEOMETRY_COLUMN VARCHAR(30) NOT NULL,
COORD_DIMENSION INTEGER,
SRID INTEGER NOT NULL,
TYPE VARCHAR(30) NOT NULL,
UNIQUE(F_TABLE_SCHEMA, F_TABLE_NAME, F_GEOMETRY_COLUMN),
CHECK(TYPE IN ('POINT', 'LINESTRING', 'POLYGON', 'MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION') ));
In this table you need to insert:
F_TABLE_SCHEMA - dbo in most cases
F_TABLE_NAME - name of your table
F_GEOMETRY_COLUMN - column where is stored geometry in your table
COORD_DIMENSION - 2 is for coordinates that contain X,Y - 3 is for coordinates that contain X,Y,Z
SRID - 3844 (EPSG code)
TYPE - POINT (or LINESTRING, POLYGON, etc)
After that you need to go GeoServer and set up the connection to your database, and in the bottom of the page you need to specify the geometry table (see the photo that is attached)
After all these steps you will be able to query your data and also to make a widget from your data.