Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
kamii47
Constraint Violating Yak Guru
353 Posts |
Posted - 2008-05-20 : 14:44:23
|
| Now, i have a project in ASP.NET and SQL Server 2005. let's call the project an image gallery, in my project i have a table named "Category" in which all the categories are in this table. also while adding a new category a new table will be created automatically with the name of that category.now, what i want is that to build a query that reads the contents of the tables that the tables name are the names of the each record in the "Category" table.Kamran ShahidSr. Software Engineer(MCSD.Net)www.netprosys.com |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-05-20 : 14:53:05
|
| Why have you designed your system this way?Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-20 : 14:59:37
|
quote: Originally posted by kamii47 Now, i have a project in ASP.NET and SQL Server 2005. let's call the project an image gallery, in my project i have a table named "Category" in which all the categories are in this table. also while adding a new category a new table will be created automatically with the name of that category.now, what i want is that to build a query that reads the contents of the tables that the tables name are the names of the each record in the "Category" table.Kamran ShahidSr. Software Engineer(MCSD.Net)www.netprosys.com
Why are you creating a new table on addition of each category? what will table consists of? |
 |
|
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2008-05-20 : 14:59:45
|
| This is the wrong approach.Use this approachTable1_MyCategoriesCatID CATNAME1 Red Images2 Blue Images3 Green ImagesTable2_ImagesImageID CATID ImageName1 2 MyBlueImage1.jpg2 1 MyREDImage1.jpg3 1 MyREDImage2.jpg4 1 MyREDImage3.jpg5 3 MyGreenImage1.jpgThen when you want to get all the information for a specific category just useSelect * from Table2_Images a where a.CatID = .... (i.e. 1,2,3)Please clarify if this is not what you are looking for. I do not see any reasont why you would want to create separate tables. |
 |
|
|
|
|
|