Showing posts with label locations. Show all posts
Showing posts with label locations. Show all posts

Thursday, March 22, 2012

Default data and log file location

How can I determine the default data and log file locations of a Smo.Server instance?

For example, my server's default location is "C:\Program Files\Microsoft SQL Server\MSSQL\Data"

Hi,

you can use the following code to get the registry values, but the documentation is not right at this point as I won′t bring back any string if not set in the registry:

Server s = new Server(".");

Console.WriteLine(s.Settings.DefaultFile);

Jens K. Suessmeyer.

http://www.sqlserver2005.de
|||

Thanks - thats what I was looking for. When the registry value is not set I will just grab the file location of the master db:

'open the master database

Dim master As Database = New Database(_server, "master")

master.Refresh()

'get the location of its mdf file

Dim masterMdfFilename = master.FileGroups.Item(0).Files.Item(0).FileName

Console.WriteLine(System.IO.Path.GetDirectoryName(masterMdfFilename))

Default data and log file location

How can I determine the default data and log file locations of a Smo.Server instance?

For example, my server's default location is "C:\Program Files\Microsoft SQL Server\MSSQL\Data"

Hi,

you can use the following code to get the registry values, but the documentation is not right at this point as I won′t bring back any string if not set in the registry:

Server s = new Server(".");

Console.WriteLine(s.Settings.DefaultFile);

Jens K. Suessmeyer.

http://www.sqlserver2005.de
|||

Thanks - thats what I was looking for. When the registry value is not set I will just grab the file location of the master db:

'open the master database

Dim master As Database = New Database(_server, "master")

master.Refresh()

'get the location of its mdf file

Dim masterMdfFilename = master.FileGroups.Item(0).Files.Item(0).FileName

Console.WriteLine(System.IO.Path.GetDirectoryName(masterMdfFilename))

Default Contraint Problem

Hello,
I have 6 SQL Server in different locations running same applications. In a
table a column has a default contsraint, It works in 3 servers but the other
3 servers it does not work the column gets NULL value.
Any Idea?
Thanks in advance,
Erdal,Can you generate the SQL script for the table that works, the table that
doesn't work, and the insert statement used?
http://www.aspfaq.com/5006
"Erdal Akbulut" <erdalim21@.yahoo.com> wrote in message
news:eMosU6yoFHA.3552@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I have 6 SQL Server in different locations running same applications. In
> a
> table a column has a default contsraint, It works in 3 servers but the
> other
> 3 servers it does not work the column gets NULL value.
> Any Idea?
> Thanks in advance,
>
> Erdal,
>
>|||This works
[CostV_LA] [numeric](21, 8) NULL CONSTRAINT [DF_tblOrderLines_CostV_LA]
DEFAULT (0),
This works too
[CostV_LA] [money] NULL CONSTRAINT [DF_tblOrderLines_CostV_LA] DEFAULT (0),
This does not.
[CostV_LA] [money] NULL CONSTRAINT [DF_tblOrderLines_CostV_LA] DEFAULT (0),
The strange thing the one that does not work today was working last month.
There is no sp updating this column.
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:%23PM%23t9yoFHA.2080@.TK2MSFTNGP14.phx.gbl...
> Can you generate the SQL script for the table that works, the table that
> doesn't work, and the insert statement used?
> http://www.aspfaq.com/5006
>
>
> "Erdal Akbulut" <erdalim21@.yahoo.com> wrote in message
> news:eMosU6yoFHA.3552@.TK2MSFTNGP10.phx.gbl...
In
>|||> This works
> [CostV_LA] [numeric](21, 8) NULL CONSTRAINT [DF_tblOrderLines_CostV_LA]
> DEFAULT (0),
> This works too
> [CostV_LA] [money] NULL CONSTRAINT [DF_tblOrderLines_CostV_LA] DEFAULT
> (0),
>
> This does not.
> [CostV_LA] [money] NULL CONSTRAINT [DF_tblOrderLines_CostV_LA] DEFAULT
> (0),
Can you give the whole CREATE TABLE script? Also summarize any differences
between the two servers, e.g. @.@.version, regional settings, DBCC
USEROPTIONS. Also, if you don't want NULL to end up in the table, your
constraints should be:
[CostV_LA] [MONEY] NOT NULL CONSTRAINT [DF_tblOrderLines_CostV_LA] DEFAULT
(0),
Do you see why it's impossible to diagnose the problem from here? Imagine
me telling you, I have two cars in my driveway, and one of them doesn't
work. What's the problem? You ask for more information. I tell you, well,
they're both Chevy Novas. Does that help?
Are you beating your head against a wall yet? I am!

> There is no sp updating this column.
There must be an INSERT statement that causes the default to either work or
not (if you do not insert data into the row, how do you know the constraint
fails to work?).
A