![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I want my application to create a new database/tables when run for the first time. I have created a stored procedure to create the new database named "budget". When I run the stored procedure, it creates the budget database but the tables are created in the "master" database. Please help. |
#3
| |||
| |||
|
|
Before the CREATE TABLE statements you should put this: USE Budget go "Shiller" <shill... (AT) gmail (DOT) com> ha scritto nel messaggionews:1172675843.097303.293060 (AT) 8g2000cwh (DOT) googlegroups.com... I want my application to create a new database/tables when run for the first time. I have created a stored procedure to create the new database named "budget". When I run the stored procedure, it creates the budget database but the tables are created in the "master" database. Please help.- Hide quoted text - - Show quoted text - |
#4
| |||
| |||
|
|
On Feb 28, 10:44 am, "Massimo-Mastino" <mast... (AT) hotmail (DOT) it> wrote: Before the CREATE TABLE statements you should put this: USE Budget go "Shiller" <shill... (AT) gmail (DOT) com> ha scritto nel messaggionews:1172675843.097303.293060 (AT) 8g2000cwh (DOT) googlegroups.com... I want my application to create a new database/tables when run for the first time. I have created a stored procedure to create the new database named "budget". When I run the stored procedure, it creates the budget database but the tables are created in the "master" database. Please help.- Hide quoted text - - Show quoted text - I tried using the USE statement, but it's not allowed in stored procedure: "a USE database statement is not allowed in a procedure, function or trigger." |
#5
| |||
| |||
|
|
"Shiller" <shillerc (AT) gmail (DOT) com> wrote in message news:1172678827.112925.18770 (AT) k78g2000cwa (DOT) googlegroups.com... On Feb 28, 10:44 am, "Massimo-Mastino" <mast... (AT) hotmail (DOT) it> wrote: Before the CREATE TABLE statements you should put this: USE Budget go "Shiller" <shill... (AT) gmail (DOT) com> ha scritto nel messaggionews:1172675843.097303.293060 (AT) 8g2000cwh (DOT) googlegroups.com... I want my application to create a new database/tables when run for the first time. I have created a stored procedure to create the new database named "budget". When I run the stored procedure, it creates the budget database but the tables are created in the "master" database. Please help.- Hide quoted text - - Show quoted text - I tried using the USE statement, but it's not allowed in stored procedure: "a USE database statement is not allowed in a procedure, function or trigger." Correct, USE is not really transact-SQL it's a control statement for query analyzer, etc. Off hand I'm not sure of a solution to your problem, but google may. I seem to recall others having similar problems. Generally though what you want to do is done by a series of scripts, not a single stored proc. |
#6
| |||
| |||
|
|
Shiller, Use a three part qualifier in your create table statement: create table MyDB.dbo.MyTable ... -- Bill "Greg D. Moore (Strider)" <mooregr_deletet... (AT) greenms (DOT) com> wrote in messagenews:K_hFh.7399$tD2.4682 (AT) newsread1 (DOT) news.pas.earthlink.net... "Shiller" <shill... (AT) gmail (DOT) com> wrote in message news:1172678827.112925.18770 (AT) k78g2000cwa (DOT) googlegroups.com... On Feb 28, 10:44 am, "Massimo-Mastino" <mast... (AT) hotmail (DOT) it> wrote: Before the CREATE TABLE statements you should put this: USE Budget go "Shiller" <shill... (AT) gmail (DOT) com> ha scritto nel messaggionews:1172675843.097303.293060 (AT) 8g2000cwh (DOT) googlegroups.com... I want my application to create a new database/tables when run for the first time. I have created a stored procedure to create the new database named "budget". When I run the stored procedure, it creates the budget database but the tables are created in the "master" database. Please help.- Hide quoted text - - Show quoted text - I tried using the USE statement, but it's not allowed in stored procedure: "a USE database statement is not allowed in a procedure, function or trigger." Correct, USE is not really transact-SQL it's a control statement for query analyzer, etc. Off hand I'm not sure of a solution to your problem, but google may. I seem to recall others having similar problems. Generally though what you want to do is done by a series of scripts, not a single stored proc.- Hide quoted text - - Show quoted text - |
#7
| |||
| |||
|
|
I want my application to create a new database/tables when run for the first time. I have created a stored procedure to create the new database named "budget". When I run the stored procedure, it creates the budget database but the tables are created in the "master" database. Please help. |
![]() |
| Thread Tools | |
| Display Modes | |
| |