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 |
quangitbk
Starting Member
4 Posts |
Posted - 2010-11-21 : 06:19:59
|
hi all, i have 1 file sql as *.sql.now i want add it to 1 new database was created.but i'm not know to do.please everybody help me.thanks all,pressing |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-11-21 : 07:26:16
|
you mean execute code contained in file in db? if yes, open sql management studio connect to server containing db,select your db from dropdown. choose file->open brose to .sql file and click execute from top menu.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
quangitbk
Starting Member
4 Posts |
Posted - 2010-11-21 : 09:40:28
|
quote: Originally posted by visakh16 you mean execute code contained in file in db? if yes, open sql management studio connect to server containing db,select your db from dropdown. choose file->open brose to .sql file and click execute from top menu.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
sorry i is a beginner.but my problem other.detailt:i have a file *sql.i was a new db :"demo".i want this file in that db.as picture that i posted.it announce result " Could not locate entry in sysdatabases for database 'quanlyHocSinh'. No entry found with that name. Make sure that the name is entered correctly."please help!sorry, i dont't know post picture,so picture this:http://www.4shared.com/photo/Gb71uKX-/picture.html |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-11-21 : 12:20:07
|
put a GO after CREATE DATABASE and USE. i.e it should beCREATE DATABASE quanlyHocSinhGOUSE quanlyHocSinhGO... ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
quangitbk
Starting Member
4 Posts |
Posted - 2010-11-21 : 18:59:41
|
quote: Originally posted by visakh16 put a GO after CREATE DATABASE and USE. i.e it should beCREATE DATABASE quanlyHocSinhGOUSE quanlyHocSinhGO... it error.i want after open db demo,in item table must have db of file sql that i was opened.you use GO, it error,and after in db demo is empty.please help.thanks all.picture after use GO:http://www.4shared.com/photo/wP70RcHK/Untitled.html------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2010-11-21 : 19:36:36
|
That's not very clear but create table has to be the first statement in a batch so you need a go before each one.If you've run it once then the databse will have been created so you don't need to run that statement again.I would run the use statement on it's own to check that it works otherwise you can end up creating objects in the wrong database.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
quangitbk
Starting Member
4 Posts |
Posted - 2010-11-21 : 20:53:30
|
well,thanks you was help.i did successful |
|
|
|
|
|
|
|