I am trying to create multiple tables out of a main table in SQL server. e.g.:
The main table looks like
A 1
A 2
A 3
B 4
B 5
B 6
The output should look like :
Table A:
A 1
A 2
A 3
Table B:
B 4
B 5
B 6
The main table is updated every week so can have different alphabets. So I want to create a dynamic query that will automatically divide the main table into 'n' different tables depending on how many different n's are there and also name the table based on the nth value.
Yes it is achievable, but Curse and Blessing Dynamic SQL by Erland Sommarskog
Possible solution using Inline Parametrized Table-Valued Function (you can use Stored Procedure if needed):
EDIT
You can use view for this and pass them to users. If you still want tables feel free to change code, you should get the idea. Why views, because table is still one and you get dynamics VIEW that can mimic your multiple tables. Also when data will be updated in main table your all views will get it immediately, no need to update/insert.
SqlFiddleDemo
DBFiddle Demo (updated)