Is there a cross wizard and sorcerer type class or a way of achieving the following. Some of the spells selection are limited like a sorcerer and other slots can be prepared like wizard? I am not looking for multiclassing but for an actual class, prestige class, or feat that achieves this.
You can, of course, just take levels in both sorcerer and wizard and have the spellcasting of both. But there is a better option:
Ultimate magus is the closest to exactly what you’re looking for
Ultimate magus is a prestige class from Complete Mage that advances the spellcasting of a class that prepares arcane spells from a book and the spellcasting of another class that casts arcane spells without preparation. So a 4th-level wizard/1st-level sorcerer or 4th-level sorcerer/1st-level wizard could take ultimate magus to advance both types of spellcasting.
In the ten levels of the class, seven advance both classes. At 1st, 4th, and 7th, it advances only one, specifically the class with the lower caster level. Using Practiced Spellcaster (Complete Arcane) and/or the illumian krau sigil (Races of Destiny) to add a caster level bonus to your lower-level class so that you get 10/10 spellcasting in your higher class and 7/10 spellcasting in your lower class. Using both, it’s possible to have, for example, a 4th-level wizard/1st-level sorcerer/10th-level ultimate magus with the spellcasting of a 14th-level wizard and an 8th-level sorcerer as a 15th-level character—i.e. 8 levels of sorcery spellcasting at the cost of only one missed wizard level.
Because wizards use Intelligence and sorcerers use Charisma, the Intelligence-based beguiler (Player’s Handbook II) is often preferred over sorcerer, since a beguiler/wizard uses Intelligence for both types of spells.
Of course, multiclassing or ultimate magus might not be what you had in mind. You might have been wondering if there were specific classes that do both. And the answer is... sort of.
The sha’ir (Dragon Compendium) does a weird pseudo-prepared spellcasting thing where you send you mini genie familiar to the Elemental Planes to collect spells for you, which works somehow. Anyway, retrieving the spell takes a few rounds or minutes, so it isn’t quite spontaneous, but it is also not the same as preparing for the whole day.
There is a variant psion called erudite (Complete Psionic) that manifests powers spontaneously from the full psion/wilder list. To prevent that from getting out of hand, it also has a limited number of “unique powers per day.” So after you’ve used that up, the only powers you can manifest for the rest of the day are the ones you’ve already manifested.
Unfortunately, this is a variant printed at the back of a rather terrible book, and the editing is shoddy. It’s unclear if the unique powers per day are per power level, or total. If the former, the erudite is incredibly overpowered. If the latter, it’s extremely weak.
If psionic powers don’t work for you, there is a Mind’s Eye web enhancement that discusses a “spell to power” variant that allows a psion to turn arcane spells into psionic powers so they can manifest those. This is pretty much busted in itself, and if combined with per-level unique powers per day, makes for hands-down the most game breaking class in the system.
The spirit shaman (Complete Divine) is similar to a spontaneous druid (without the animal companion or wild shape), except uniquely, it gets to change its spells known every day. This is like spell preparation in D&D 5e, if you’re familiar with that. It’s also similar to the erudite, except you have to pick your unique spells at the start of the day. Unlike the erudite, spirit shaman is reasonably well-edited and balanced, though it is a little painful to consider just because the druid is so much stronger in basically every way.
As seen in nijineko’s answer, the beholder mage (Lords of Madness) casts spontaneously off of the entire sorcerer/wizard list. There’s no preparation involved at all, but there’s also no need to.
It’s also flat-out broken and should be banned at every table ever.
Without a fancy class
Maybe you want to add a bit of spontaneity to your wizard, or have your sorcerer go into things a bit prepared. There are options for those.
As A_S00’s fine answer points out, Arcane Preparation (Complete Arcane) allows a spontaneous spellcaster to prepare spells, and Uncanny Foresight (Exemplars of Evil) allows a prepared spellcaster to cast a few spontaneously.
Just by using the default preparation mechanics
It’s a little-known fact that prepared spellcasters don’t have to prepare all their spells at the beginning of the day:
When preparing spells for the day, a wizard can leave some of these spell slots open. Later during that day, she can repeat the preparation process as often as she likes, time and circumstances permitting. During these extra sessions of preparation, the wizard can fill these unused spell slots. She cannot, however, abandon a previously prepared spell to replace it with another one or fill a slot that is empty because she has cast a spell in the meantime. That sort of preparation requires a mind fresh from rest. Like the first session of the day, this preparation takes at least 15 minutes, and it takes longer if the wizard prepares more than one-quarter of her spells.
(Wizard Spell Selection & Preparation—note that at the time wizards were the only prepared arcane spellcasters)
A divine spellcaster does not have to prepare all his spells at once. However, the character’s mind is considered fresh only during his or her first daily spell preparation, so a divine spellcaster cannot fill a slot that is empty because he or she has cast a spell or abandoned a previously prepared spell.
(Divine Spell Selection & Preparation—note that at the time there were no spontaneous divine spellcasters)
Like the sha’ir, this isn’t properly spontaneous—you need 15 minutes to prepare spells you left unprepared—but it’s rather different from preparing all of your spells at the beginning of the day.
There's no base class in the game that just straightforwardly gives you the abilities of both a Wizard and a Sorcerer. However, there are plenty of options that sorta-kinda fit:
- Ultimate Magus (Complete Mage, p. 77): A prestige class that requires you to be able to cast both spontaneous and prepared arcane spells, and progresses both. It offers 10/10 spellcasting progression for one of your spellcasting classes, and 7/10 for the other. Because of the way its Spellcasting class feature works, there are some clever tricks involving caster level you can use to influence which of your classes ends up getting progressed at each level. You can check out this old handbook (archive link) for details on how to best build a character around this class.
- Arcane Preparation (Complete Arcane, p. 73): A feat that allows a spontaneous caster to use some of their spell slots for prepared casting (like a Wizard) instead of their normal spontaneous casting. This lets them take advantage of stuff that requires prepared casting, or works better on prepared spells (like using metamagic without increasing the casting time of the spell like a Sorcerer usually would).
- Uncanny Forethought (Exemplars of Evil, p. 26): A feat that allows a Wizard to reserve a small number of their spell slots and use them to spontaneously cast any spell they know. This lets a Wizard do a limited amount of casting like a Sorcerer (though the number of spells you can cast this way each day is limited to your Int bonus).
- Spontaneous Divination (Complete Champion, p. 52): An alternate class feature for Wizard that allows them to sacrifice any prepared spell to spontaneously cast any Divination spell (the same way Clerics can sacrifice spells to spontaneously cast Cure/Inflict Wounds spells). This isn't restricted to spells you know, which is very powerful, although of course being restricted to Divination spells puts a limit on what you can do with this ability.
- Gestalt variant rules: This is a set of variant rules from Unearthed Arcana, the core of which is to allow player characters to choose two classes at each character level. You could use these rules to play a Wizard 20 // Sorcerer 20 without issue. However, these rules are not intended to be generally available to players in a normal game — gestalt is a variant ruleset explicitly designed to result in characters that are much more powerful than normal, and you should only expect it to be allowed if your DM is giving everyone the option to play gestalt.
The Beholder Mage prestige from Lords of Madness is your class for the ultimate combining of wizard and sorcerer advantages. (Pun intended)
- learn all arcane spells as a wizard but without any spellbook required.
- cast any arcane spells you know as a sorcerer.
- have to qualify race-wise as a Beholder to take the class.
- have to put out your central anti-magic eye as part of the qualifications.
Due to the cons of this prestige, most people choose not to consider it.
Just as a side note, if you are instead trying to combine the advantages of prepared casting and spontaneous casting, but are willing to put up with having a few levels of divine classes, then you could also consider the Geomancer prestige.