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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-12-09 : 06:53:42
|
| Sujatha writes "Hi, I am using SQL Server 2000. I want to write a stored procedure in which i first check whether there is database with some name 'mytest'.if it doesn't exist i have to create the one and also have to create a table in the database 'mytest'.How this can be done?i am able to create the database. but i am not able to create the table in the new database. Its urgent. Please provide me a solution.Thanks & Regards,Sujatha" |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-12-09 : 06:54:08
|
| Why are you using stored procedures to create databases? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-12-09 : 08:51:40
|
| You should avoid creating objects on the Fly. It should be done at once and you should design the Procedures to do Data Manipulations and not Data DefinitionsMadhivananFailing to plan is Planning to fail |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2005-12-09 : 09:32:51
|
| As the others sugest, its not advisable to create objects on the fly, but if u want to do some sort of experiment here is a suggestion :Instead of giving just the table name, use the fully qualified name of the table asMyServerName.MYDBName.DBOwner.MyTblNameHere all MyServerName, MYDBName & MyTblName should have the real names (u can ommit the Myserver. part if u r usinng the same server) and DBOwner is the owner name in the DB u created. (May be ie ur user name when u created the DB or may be dbo)So an eg. would bePubs.dbo.NewTable instead of NewTable |
 |
|
|
|
|
|