Depends on the valve type and style:
Threaded valves - Remove and replace with the same style, size and length or longer if the piping can be cut and re-threaded.
Welded either socket or butt welded - If installed without unions - Remove the valve by cutting the piping and weld in the replacement valve with suitable length stub ends. If installed with unions - Remove the valve and piping at the unions, welding in replacement new valve, union halves and suitable length of stub piping;
Flanged - Remove and replace with same, style, size and length
Three Piece - remove the center piece and replace with new center section.