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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 m confused about using dbo and ..

Author  Topic 

rtutus
Aged Yak Warrior

522 Posts

Posted - 2007-01-04 : 17:38:27
Hi,
I will give someone a script that creates a database using :
create database mydatabase
my question: can I use myDatabase.dbo...... and myDatabase..Whatevertable in order to manipulate the database objects or should I be careful with putting dbo in my script.

The reason is that I will have to give the following script to someone to execute on his instance and I don t want it to fail.

The script creates a database mosaikDB737, create a table called FileListInput in that database and populates a second table called DBlistOutput with the list of names of all databases in the instance.

Please let me know if there are any (BAD) chances for the following script to fail.


create database mosaikDB737
go
use mosaikDB737

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[FileListInput]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[FileListInput](
[FileName] [char](50) NULL
) ON [PRIMARY]
END

use master
select name into mosaikDB737.dbo.DBlistOutput from sysdatabases where name not in ('master','tempdb','model','msdb')
select * from mosaikDB737.dbo.DBlistOutput

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-01-04 : 20:06:16
one way it could fail is if mosaikDB737 already exists.

EDIT: that is, if you run the script twice, it's guaranteed to fail the second time


www.elsasoft.org
Go to Top of Page

rtutus
Aged Yak Warrior

522 Posts

Posted - 2007-01-04 : 22:25:18
if that s it then i guess i am fine cause i can make sure with him that s not the case
Thanks a lot
Go to Top of Page

rtutus
Aged Yak Warrior

522 Posts

Posted - 2007-01-04 : 23:06:05
Can I give u please my whole script and see if it will work on your instance as is. It s related to the search that help me with for keywords loaded from a csv file?
All it does it takes it, creates a database and 3 tables, then it put the instance logins in 1st table, the instance list of databases in second instance and it loads the csv file in an other table, then it looks for all the keywords that exist in that csv file and look them up in the Stored procedures, then it outputs the result in a table searchresult
Let me know if any one doesn t mind.
Thanks a lot
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-01-04 : 23:08:59
why can't you test it on your own servers?


www.elsasoft.org
Go to Top of Page

rtutus
Aged Yak Warrior

522 Posts

Posted - 2007-01-04 : 23:18:16
i don t have a real database with many stored procedures?
But I guess I should do that. The script is not for me. I m just doing it but another company will run ot so i don t won t to be ashamed if something doesn t work
But i think u re right i should figure it out if i wanna learn. right:)
Go to Top of Page
   

- Advertisement -