Showing posts with label program. Show all posts
Showing posts with label program. 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))

Monday, March 19, 2012

Decoding Days Bitwise AND

Hello All

I'm working on a recurring multi-day appointment program. Basically the user can choose a meeting on multiple days of the week over a span of time. For example: Tuesday and Thursday from 10:00 to 10:30 from December 1st 2004 to February 27th 2005.

So I've decided the best way to handle this is to assign a value to each day of the week like so:
MON = 1
TUE = 2
WED = 4
THU = 8
FRI = 16
SAT = 32
SUN = 64

So if the user picks TUE and THU that would be 2 + 8 = 10. The value is unique and seems to work.

So the values would be:
@.begin_date = '12/01/2004'
@.begin_time = '10:00 AM'
@.end_date = '02/27/2005'
@.end_time = '10:30 AM'
@.recur_days = 10

Now I want to pass the values to stored procedure that will decode the recur_days variable and create entries in a table for each date. I'm struggling to figure out 2 things

1. How do I decode the 10 back into 2(TUE) + 8(THU) ( I think it has something to do with the bitwise AND "&" operator but I'm not sure how to use it.)

2. What is the best way to loop through the date range and create a record for each day?

Regards
RussI would probably create another table that decodes the possible values that you would come up with, for example

Create table decode (
TtlValue int,
PtValue int
)

Then have a row for each separate value like for 10
it would be

insert decode(TtlValue, PtValue)
values(10, 8)
insert decode(TtlValue, PtValue)
values(10, 2)

after you did that your proc could just "walk the table" looking for values
that equalled your sum value.

Example:
declare @.ttlvalue int,
@.x int

select @.ttlvalue = the value of your total sums

select @.x = min(PtValue)
from decode
where TtlValue = @.ttlvalue

while @.x is not null
BEGIN
do whatever you need in here then when you're finished, move to the next row

select @.x = min(PtValue)
from decode
where TtlValue = @.ttlvalue
and PtValue > @.x
END

hope that might help?

Nick|||Use of bitwise AND operator:

Declare @.TestDate int
Declare @.TestBitwise int
set @.TestDate = 2 --Tuesday
set @.TestBitwise = 10 --Tuesday and Thursday = 2 + 8

--Check for Tuesday:
if @.TestDate & @.TestBitwise = @.TestDate
select 'Yes, Tuesday'
else select 'No, not Tuesday'

set @.TestBitwise = 9 --Monday and Thursday = 1 + 8
--Check for Tuesday:
if @.TestDate & @.TestBitwise = @.TestDate
select 'Yes, Tuesday'
else select 'No, not Tuesday'

Sunday, February 19, 2012

debugger question

Is there any good debugger program for SQL 2000 trigger and package?
Never did that to packages, but you can debug triggers if you debug a
stored procedure calling a DML which fires the trigger, the debugger
will automagically jump in.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
|||Is there any third party application which can do the debugging?
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1126593394.406063.45780@.g44g2000cwa.googlegro ups.com...
> Never did that to packages, but you can debug triggers if you debug a
> stored procedure calling a DML which fires the trigger, the debugger
> will automagically jump in.
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
>

Friday, February 17, 2012

debugger question

Is there any good debugger program for SQL 2000 trigger and package?Never did that to packages, but you can debug triggers if you debug a
stored procedure calling a DML which fires the trigger, the debugger
will automagically jump in.
HTH, Jens Suessmeyer.
--
http://www.sqlserver2005.de
--|||Is there any third party application which can do the debugging?
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1126593394.406063.45780@.g44g2000cwa.googlegroups.com...
> Never did that to packages, but you can debug triggers if you debug a
> stored procedure calling a DML which fires the trigger, the debugger
> will automagically jump in.
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
>

debugger question

Is there any good debugger program for SQL 2000 trigger and package?Never did that to packages, but you can debug triggers if you debug a
stored procedure calling a DML which fires the trigger, the debugger
will automagically jump in.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--|||Is there any third party application which can do the debugging?
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1126593394.406063.45780@.g44g2000cwa.googlegroups.com...
> Never did that to packages, but you can debug triggers if you debug a
> stored procedure calling a DML which fires the trigger, the debugger
> will automagically jump in.
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
>