How to dynamically create table, fields in the MS SQL express database?

Need to use 'sp_executesql'. You can't run it as ad-hoc query.

Check out the sample dynamic script here.

Ad-hoc query is the opposite of dynamic query.

Dynamic query means to construct a query with dynamic variables into a string and invoke another process to interpret the script.

Ad-hoc query means running the script with current process, not meant for dynamic purposes and usually ad-hoc. Check out here.

For more details specs, check out here.

Comments