Showing posts with label creating. Show all posts
Showing posts with label creating. Show all posts

Sunday, March 25, 2012

Do I need these OLEDB properties when opening a database?

Howdy folks!

If I set the following three properties when creating a database, do I need to set the same properties when I open the same database later?

sscedbprop[0].dwPropertyID = DBPROP_SSCE_AUTO_SHRINK_THRESHOLD;
sscedbprop[0].dwOptions = DBPROPOPTIONS_REQUIRED;
sscedbprop[0].vValue.vt = VT_I4;
sscedbprop[0].vValue.intVal = 100;

sscedbprop[1].dwPropertyID = DBPROP_SSCE_MAX_DATABASE_SIZE;
sscedbprop[1].dwOptions = DBPROPOPTIONS_REQUIRED;
sscedbprop[1].vValue.vt = VT_I4;
sscedbprop[1].vValue.intVal = 4091;

sscedbprop[2].dwPropertyID = DBPROP_SSCE_ENCRYPTDATABASE;
sscedbprop[2].dwOptions = DBPROPOPTIONS_REQUIRED;
sscedbprop[2].vValue.vt = VT_BOOL;
sscedbprop[2].vValue.boolVal = (a_bEncrypted==TRUE)?VARIANT_TRUE:VARIANT_FALSE;

Thanks!

BTW, why is the max size not 4096?

The first two properties can vary from session to session, but not the third. When you create a database with encryption, it must always be opened with that property (AFAIK). The auto shrink threshold and max database size have no impact on the database file format and thus don't persist.

The 4096 vs 4091 question also baffles me...

|||Awesome, thanks Joao.

Do I need cursors?

I am creating a stored procedure to send emails (with xp_sendmail, I think)
based on certain conditions. This is my logic:
I need to loop through all of the Table1 records.
if Table2 exists for Table1 and Table2.column='T'
send variation 1 of email
else if table2 exists for table 1 and Table2.column='F'
send variation 2 of email
else if table3 exists for table 1
send variation 3 of email
Should I use a cursor to loop through the Table1 records? Or should I join
Table1 and Table2/Table3 and not have a top level query? I'm thinking I
should not use a cursor.
My second problem is this. Depending on the email variation I need to loop
through some records and concatenate their values. Do I need a cursor for
that? Or do I have other options?
Thanks for any help, I really appreciate it.Nick
DECLARE @.EmailName VARCHAR(100),@.userid VARCHAR(20)
IF EXISTS (SELECT * FROM Table2 JOIN Table1 ON Table2.pk=Table1.pk AND
Table2.column='T')

> My second problem is this. Depending on the email variation I need to loop
> through some records and concatenate their values. Do I need a cursor for
> that? Or do I have other options?
SET @.userid='john,arie,alex'
SELECT @.EmailName=@.EmailName+COALESCE(Emailadd,
'') +',' FROM users where
CHARINDEX(',' + userid + ',',','+ @.userid +',')>0 and EmailName IS NOT
NULL
SET @.EmailName=LEFT(@.EmailName,LEN(@.EmailNam
e)-1)
--Send emails
I'm currently unable to test it but I'm sure it gives you an idea.
"Nick" <nickfinity@.nospam.nospam> wrote in message
news:48C35529-4878-455F-9DCC-F97057A4A5B8@.microsoft.com...
>I am creating a stored procedure to send emails (with xp_sendmail, I think)
> based on certain conditions. This is my logic:
> I need to loop through all of the Table1 records.
> if Table2 exists for Table1 and Table2.column='T'
> send variation 1 of email
> else if table2 exists for table 1 and Table2.column='F'
> send variation 2 of email
> else if table3 exists for table 1
> send variation 3 of email
> Should I use a cursor to loop through the Table1 records? Or should I join
> Table1 and Table2/Table3 and not have a top level query? I'm thinking I
> should not use a cursor.
> My second problem is this. Depending on the email variation I need to loop
> through some records and concatenate their values. Do I need a cursor for
> that? Or do I have other options?
> Thanks for any help, I really appreciate it.|||>From the limited information you've posted, it sounds like a CASE
statement is what you're looking for. In general, the only time I ever
find that I must use a cursor is when I have to call a stored procedure
on each value in a resultset. They seem to be much more useful to me in
ad hoc situations than in deployed solutions.
CASE Example in an UPDATE (sorry for the poor formatting):
UPDATE <tablealias1>
SET EmailAddress = CASE WHEN <condition1> THEN <expression>
WHEN <condition2> THEN <expression> ELSE <expression> END
FROM Table1 <tablealias1> INNER JOIN Table2 ON <...>
WHERE <condition>

Thursday, March 22, 2012

Do I have to reinitialize snapshot if a new table added?

Hello,

After creating a publication for Merge Replication, if I need to add or drop a simple table, do I have to reinitialize the snapshot all over again?

Thanks

Ekrem ?nsoy

Hello again,

I'm sorry for taking your time but I've found the answer from the Books Online (http://msdn2.microsoft.com/en-us/library/ms152493.aspx)

Thanks

Ekrem ?nsoy

Wednesday, March 7, 2012

Divide by a first row of resultset in a matrix

I'm creating my first matrix based report, and find that some things that
work with tables doesn't work the same way with matrix.
My resultset comes from an MDX statement. It looks something like this
..............................Registered hours ..........Amount
.............Total.....................10...................
1000
Month1....Group 1..................6.....................600
.............Group
2..................4.....................400
.............Total.....................12...................
1200
Month2....Group 1..................8.....................800
.............Group
2..................4.....................400
The customer wants to display the values for the months next to each other,
for each value. Now, I've managed to get this with a matrix, having the
[static group] ordered on top. (Thanks to Ohjoo Kwon).
BUT one of my columns is supposed to be "Group Result as % of total result."
Meaning for Group1 in Month1 I need to divide 600 on the Total Amount. The
first row in my result set is always a calculated total for that month. So,
when using tables, I usually just do =Amount/First(Amount), and that works
like a charm. When I try to do that in a matrix, all I get in return is
"100%". So my guess is that in a matrix, I can't use First() the same way as
in a table. But how can I do the division? How to divide "Any Row" by "First
Row"?
All help appreciated.
Kaisa M. LindahlYou have to provide the "right" scope for the aggregate function. Try one of
the two following expressions to divide by the first row:
=Sum(Fields!Amount.Value) / First(Fields!Amount.Value, "DataSetName")
=Sum(Fields!Amount.Value) / First(Fields!Amount.Value, "MatrixName")
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Kaisa M. Lindahl" <kaisaml@.hotmail.com> wrote in message
news:enVnqz6BFHA.2260@.TK2MSFTNGP14.phx.gbl...
> I'm creating my first matrix based report, and find that some things that
> work with tables doesn't work the same way with matrix.
> My resultset comes from an MDX statement. It looks something like this
> ..............................Registered hours
..........Amount
>
.............Total.....................10...................
> 1000
> Month1....Group 1..................6.....................600
> .............Group
> 2..................4.....................400
>
.............Total.....................12...................
> 1200
> Month2....Group 1..................8.....................800
> .............Group
> 2..................4.....................400
> The customer wants to display the values for the months next to each
other,
> for each value. Now, I've managed to get this with a matrix, having the
> [static group] ordered on top. (Thanks to Ohjoo Kwon).
> BUT one of my columns is supposed to be "Group Result as % of total
result."
> Meaning for Group1 in Month1 I need to divide 600 on the Total Amount. The
> first row in my result set is always a calculated total for that month.
So,
> when using tables, I usually just do =Amount/First(Amount), and that works
> like a charm. When I try to do that in a matrix, all I get in return is
> "100%". So my guess is that in a matrix, I can't use First() the same way
as
> in a table. But how can I do the division? How to divide "Any Row" by
"First
> Row"?
> All help appreciated.
> Kaisa M. Lindahl
>|||Thanks.
It worked with
=Sum(Fields!Amount.Value) / First(Fields!Amount.Value, "DataSetName")
Kaisa
"Robert Bruckner [MSFT]" <robruc@.online.microsoft.com> wrote in message
news:etV2GOOCFHA.1392@.tk2msftngp13.phx.gbl...
> You have to provide the "right" scope for the aggregate function. Try one
of
> the two following expressions to divide by the first row:
> =Sum(Fields!Amount.Value) / First(Fields!Amount.Value, "DataSetName")
> =Sum(Fields!Amount.Value) / First(Fields!Amount.Value, "MatrixName")
> --
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
> "Kaisa M. Lindahl" <kaisaml@.hotmail.com> wrote in message
> news:enVnqz6BFHA.2260@.TK2MSFTNGP14.phx.gbl...
> > I'm creating my first matrix based report, and find that some things
that
> > work with tables doesn't work the same way with matrix.
> > My resultset comes from an MDX statement. It looks something like this
> >
> > ..............................Registered hours
> ..........Amount
> >
>
.............Total.....................10...................
> > 1000
> > Month1....Group
1..................6.....................600
> > .............Group
> > 2..................4.....................400
> >
> >
>
.............Total.....................12...................
> > 1200
> > Month2....Group
1..................8.....................800
> > .............Group
> > 2..................4.....................400
> >
> > The customer wants to display the values for the months next to each
> other,
> > for each value. Now, I've managed to get this with a matrix, having the
> > [static group] ordered on top. (Thanks to Ohjoo Kwon).
> >
> > BUT one of my columns is supposed to be "Group Result as % of total
> result."
> > Meaning for Group1 in Month1 I need to divide 600 on the Total Amount.
The
> > first row in my result set is always a calculated total for that month.
> So,
> > when using tables, I usually just do =Amount/First(Amount), and that
works
> > like a charm. When I try to do that in a matrix, all I get in return is
> > "100%". So my guess is that in a matrix, I can't use First() the same
way
> as
> > in a table. But how can I do the division? How to divide "Any Row" by
> "First
> > Row"?
> >
> > All help appreciated.
> >
> > Kaisa M. Lindahl
> >
> >
>|||I just realized an error in my original code. What Robert suggested (below)
works for dividing by the very first row of the result set.
Unfortunately, I need to divide the right number with the right first row...
I'll explain
My result looks like this:
.......................Measures_Amount ...
............AllGrps...100
............Grp1........30
200409...Grp2........30
............Grp3.......40
............AllGrps....120
............Grp1........40
200309...Grp2........40
............Grp3........40
My report looks someting like this
.............Measures_Amount.....%ofTotalAmt
Group........200309|200409...200309|200409
Total..............120|...100........100%|...100%
Grp1...............40|....30.........33%|....30%
Grp2...............40|....30.........33%|....30%
Grp3...............40|....40.........33%|....40%
Today I realized that my statement
=First(Fields!Measures_Amount.Value)/ First(Fields!Measures_Amount.Value,
"OmsetningHT")
doesn't work quite as planned. This will divide all rows with the very first
row, which is the total for 200409. Suddenly all results from 200309 are
divided by the total for 200409, which is wrong.
So I need a way to divide a group result by the correct total in my matrix.
The months are organized in a column group.
All help appreciated!
Kaisa M. Lindahl
"Robert Bruckner [MSFT]" <robruc@.online.microsoft.com> wrote in message
news:etV2GOOCFHA.1392@.tk2msftngp13.phx.gbl...
> You have to provide the "right" scope for the aggregate function. Try one
of
> the two following expressions to divide by the first row:
> =Sum(Fields!Amount.Value) / First(Fields!Amount.Value, "DataSetName")
> =Sum(Fields!Amount.Value) / First(Fields!Amount.Value, "MatrixName")
> --
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
> "Kaisa M. Lindahl" <kaisaml@.hotmail.com> wrote in message
> news:enVnqz6BFHA.2260@.TK2MSFTNGP14.phx.gbl...
> > I'm creating my first matrix based report, and find that some things
that
> > work with tables doesn't work the same way with matrix.
> > My resultset comes from an MDX statement. It looks something like this
> >
> > ..............................Registered hours
> ..........Amount
> >
>
.............Total.....................10...................
> > 1000
> > Month1....Group
1..................6.....................600
> > .............Group
> > 2..................4.....................400
> >
> >
>
.............Total.....................12...................
> > 1200
> > Month2....Group
1..................8.....................800
> > .............Group
> > 2..................4.....................400
> >
> > The customer wants to display the values for the months next to each
> other,
> > for each value. Now, I've managed to get this with a matrix, having the
> > [static group] ordered on top. (Thanks to Ohjoo Kwon).
> >
> > BUT one of my columns is supposed to be "Group Result as % of total
> result."
> > Meaning for Group1 in Month1 I need to divide 600 on the Total Amount.
The
> > first row in my result set is always a calculated total for that month.
> So,
> > when using tables, I usually just do =Amount/First(Amount), and that
works
> > like a charm. When I try to do that in a matrix, all I get in return is
> > "100%". So my guess is that in a matrix, I can't use First() the same
way
> as
> > in a table. But how can I do the division? How to divide "Any Row" by
> "First
> > Row"?
> >
> > All help appreciated.
> >
> > Kaisa M. Lindahl
> >
> >
>|||This problem just resurfaced.
Anyone want to give it some thought?
Is it possible to check for something like
if month = Parameters!FirstPeriod.Value then
'use this row
end if ?
Kaisa
"Kaisa M. Lindahl" <kaisaml@.hotmail.com> wrote in message
news:OACV70qDFHA.1296@.TK2MSFTNGP10.phx.gbl...
> I just realized an error in my original code. What Robert suggested
(below)
> works for dividing by the very first row of the result set.
> Unfortunately, I need to divide the right number with the right first
row...
> I'll explain
> My result looks like this:
> .......................Measures_Amount ...
> ............AllGrps...100
> ............Grp1........30
> 200409...Grp2........30
> ............Grp3.......40
> ............AllGrps....120
> ............Grp1........40
> 200309...Grp2........40
> ............Grp3........40
> My report looks someting like this
> .............Measures_Amount.....%ofTotalAmt
> Group........200309|200409...200309|200409
> Total..............120|...100........100%|...100%
> Grp1...............40|....30.........33%|....30%
> Grp2...............40|....30.........33%|....30%
> Grp3...............40|....40.........33%|....40%
> Today I realized that my statement
> =First(Fields!Measures_Amount.Value)/ First(Fields!Measures_Amount.Value,
> "OmsetningHT")
> doesn't work quite as planned. This will divide all rows with the very
first
> row, which is the total for 200409. Suddenly all results from 200309 are
> divided by the total for 200409, which is wrong.
> So I need a way to divide a group result by the correct total in my
matrix.
> The months are organized in a column group.
> All help appreciated!
> Kaisa M. Lindahl
>
> "Robert Bruckner [MSFT]" <robruc@.online.microsoft.com> wrote in message
> news:etV2GOOCFHA.1392@.tk2msftngp13.phx.gbl...
> > You have to provide the "right" scope for the aggregate function. Try
one
> of
> > the two following expressions to divide by the first row:
> > =Sum(Fields!Amount.Value) / First(Fields!Amount.Value, "DataSetName")
> > =Sum(Fields!Amount.Value) / First(Fields!Amount.Value, "MatrixName")
> >
> > --
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.
> >
> >
> > "Kaisa M. Lindahl" <kaisaml@.hotmail.com> wrote in message
> > news:enVnqz6BFHA.2260@.TK2MSFTNGP14.phx.gbl...
> > > I'm creating my first matrix based report, and find that some things
> that
> > > work with tables doesn't work the same way with matrix.
> > > My resultset comes from an MDX statement. It looks something like this
> > >
> > > ..............................Registered hours
> > ..........Amount
> > >
> >
>
.............Total.....................10...................
> > > 1000
> > > Month1....Group
> 1..................6.....................600
> > > .............Group
> > > 2..................4.....................400
> > >
> > >
> >
>
.............Total.....................12...................
> > > 1200
> > > Month2....Group
> 1..................8.....................800
> > > .............Group
> > > 2..................4.....................400
> > >
> > > The customer wants to display the values for the months next to each
> > other,
> > > for each value. Now, I've managed to get this with a matrix, having
the
> > > [static group] ordered on top. (Thanks to Ohjoo Kwon).
> > >
> > > BUT one of my columns is supposed to be "Group Result as % of total
> > result."
> > > Meaning for Group1 in Month1 I need to divide 600 on the Total Amount.
> The
> > > first row in my result set is always a calculated total for that
month.
> > So,
> > > when using tables, I usually just do =Amount/First(Amount), and that
> works
> > > like a charm. When I try to do that in a matrix, all I get in return
is
> > > "100%". So my guess is that in a matrix, I can't use First() the same
> way
> > as
> > > in a table. But how can I do the division? How to divide "Any Row" by
> > "First
> > > Row"?
> > >
> > > All help appreciated.
> > >
> > > Kaisa M. Lindahl
> > >
> > >
> >
> >
>|||If you can group on year or whatever is relevant in your scenario, then
within that group, =First(Fields!Amount.Value) should refer to the
first value in that group. As Robert said, it's all about scope with
aggregate functions. By grouping the data, you are limiting the scope,
which is what you want.
Chris
Kaisa M. Lindahl wrote:
> This problem just resurfaced.
> Anyone want to give it some thought?
> Is it possible to check for something like
> if month = Parameters!FirstPeriod.Value then
> 'use this row
> end if ?
> Kaisa
> "Kaisa M. Lindahl" <kaisaml@.hotmail.com> wrote in message
> news:OACV70qDFHA.1296@.TK2MSFTNGP10.phx.gbl...
> > I just realized an error in my original code. What Robert suggested
> (below)
> > works for dividing by the very first row of the result set.
> > Unfortunately, I need to divide the right number with the right
> > first
> row...
> > I'll explain
> >
> > My result looks like this:
> > .......................Measures_Amount ...
> > ............AllGrps...100
> > ............Grp1........30
> > 200409...Grp2........30
> > ............Grp3.......40
> > ............AllGrps....120
> > ............Grp1........40
> > 200309...Grp2........40
> > ............Grp3........40
> >
> > My report looks someting like this
> >
> > .............Measures_Amount.....%ofTotalAmt
> > Group........200309|200409...200309|200409
> > Total..............120|...100........100%|...100%
> > Grp1...............40|....30.........33%|....30%
> > Grp2...............40|....30.........33%|....30%
> > Grp3...............40|....40.........33%|....40%
> >
> > Today I realized that my statement
> > =First(Fields!Measures_Amount.Value)/
> > First(Fields!Measures_Amount.Value, "OmsetningHT")
> > doesn't work quite as planned. This will divide all rows with the
> > very
> first
> > row, which is the total for 200409. Suddenly all results from
> > 200309 are divided by the total for 200409, which is wrong.
> >
> > So I need a way to divide a group result by the correct total in my
> matrix.
> > The months are organized in a column group.
> >
> > All help appreciated!
> >
> > Kaisa M. Lindahl
> >
> >
> > "Robert Bruckner [MSFT]" <robruc@.online.microsoft.com> wrote in
> > message news:etV2GOOCFHA.1392@.tk2msftngp13.phx.gbl...
> > > You have to provide the "right" scope for the aggregate function.
> > > Try
> one
> > of
> > > the two following expressions to divide by the first row:
> > > =Sum(Fields!Amount.Value) / First(Fields!Amount.Value,
> > > "DataSetName") =Sum(Fields!Amount.Value) /
> > > First(Fields!Amount.Value, "MatrixName")
> > >
> > > --
> > > This posting is provided "AS IS" with no warranties, and confers
> > > no
> > rights.
> > >
> > >
> > > "Kaisa M. Lindahl" <kaisaml@.hotmail.com> wrote in message
> > > news:enVnqz6BFHA.2260@.TK2MSFTNGP14.phx.gbl...
> > > > I'm creating my first matrix based report, and find that some
> > > > things
> > that
> > > > work with tables doesn't work the same way with matrix.
> > > > My resultset comes from an MDX statement. It looks something
> > > > like this
> > > >
> > > > ..............................Registered hours
> > > ..........Amount
> > > >
> > >
> >
> .............Total.....................10...............
> .....
> > > > 1000
> > > > Month1....Group
> > 1..................6.....................600
> > > > .............Group
> > > > 2..................4.....................400
> > > >
> > > >
> > >
> >
> .............Total.....................12...............
> .....
> > > > 1200
> > > > Month2....Group
> > 1..................8.....................800
> > > > .............Group
> > > > 2..................4.....................400
> > > >
> > > > The customer wants to display the values for the months next to
> > > > each
> > > other,
> > > > for each value. Now, I've managed to get this with a matrix,
> > > > having
> the
> > > > [static group] ordered on top. (Thanks to Ohjoo Kwon).
> > > >
> > > > BUT one of my columns is supposed to be "Group Result as % of
> > > > total
> > > result."
> > > > Meaning for Group1 in Month1 I need to divide 600 on the Total
> > > > Amount.
> > The
> > > > first row in my result set is always a calculated total for that
> month.
> > > So,
> > > > when using tables, I usually just do =Amount/First(Amount), and
> > > > that
> > works
> > > > like a charm. When I try to do that in a matrix, all I get in
> > > > return
> is
> > > > "100%". So my guess is that in a matrix, I can't use First()
> > > > the same
> > way
> > > as
> > > > in a table. But how can I do the division? How to divide "Any
> > > > Row" by
> > > "First
> > > > Row"?
> > > >
> > > > All help appreciated.
> > > >
> > > > Kaisa M. Lindahl
> > > >
> > > >
> > >
> > >
> >
> >|||OK, thanks to both. I finally figured it out. :)
I'm still getting confused by when to use what scope. The final solution was
to change from
First(Fields!Amount.Value, "Dataset") to First(Fields!Amount.Value,
"MatrixColumnGroupName").
Kaisa M. Lindahl
"Chris McGuigan" <chris.mcguigan@.zycko.com> wrote in message
news:uO5VPAzIFHA.2656@.TK2MSFTNGP09.phx.gbl...
> If you can group on year or whatever is relevant in your scenario, then
> within that group, =First(Fields!Amount.Value) should refer to the
> first value in that group. As Robert said, it's all about scope with
> aggregate functions. By grouping the data, you are limiting the scope,
> which is what you want.
> Chris
>
> Kaisa M. Lindahl wrote:
> > This problem just resurfaced.
> > Anyone want to give it some thought?
> >
> > Is it possible to check for something like
> > if month = Parameters!FirstPeriod.Value then
> > 'use this row
> > end if ?
> >
> > Kaisa
> >
> > "Kaisa M. Lindahl" <kaisaml@.hotmail.com> wrote in message
> > news:OACV70qDFHA.1296@.TK2MSFTNGP10.phx.gbl...
> > > I just realized an error in my original code. What Robert suggested
> > (below)
> > > works for dividing by the very first row of the result set.
> > > Unfortunately, I need to divide the right number with the right
> > > first
> > row...
> > > I'll explain
> > >
> > > My result looks like this:
> > > .......................Measures_Amount ...
> > > ............AllGrps...100
> > > ............Grp1........30
> > > 200409...Grp2........30
> > > ............Grp3.......40
> > > ............AllGrps....120
> > > ............Grp1........40
> > > 200309...Grp2........40
> > > ............Grp3........40
> > >
> > > My report looks someting like this
> > >
> > > .............Measures_Amount.....%ofTotalAmt
> > > Group........200309|200409...200309|200409
> > > Total..............120|...100........100%|...100%
> > > Grp1...............40|....30.........33%|....30%
> > > Grp2...............40|....30.........33%|....30%
> > > Grp3...............40|....40.........33%|....40%
> > >
> > > Today I realized that my statement
> > > =First(Fields!Measures_Amount.Value)/
> > > First(Fields!Measures_Amount.Value, "OmsetningHT")
> > > doesn't work quite as planned. This will divide all rows with the
> > > very
> > first
> > > row, which is the total for 200409. Suddenly all results from
> > > 200309 are divided by the total for 200409, which is wrong.
> > >
> > > So I need a way to divide a group result by the correct total in my
> > matrix.
> > > The months are organized in a column group.
> > >
> > > All help appreciated!
> > >
> > > Kaisa M. Lindahl
> > >
> > >
> > > "Robert Bruckner [MSFT]" <robruc@.online.microsoft.com> wrote in
> > > message news:etV2GOOCFHA.1392@.tk2msftngp13.phx.gbl...
> > > > You have to provide the "right" scope for the aggregate function.
> > > > Try
> > one
> > > of
> > > > the two following expressions to divide by the first row:
> > > > =Sum(Fields!Amount.Value) / First(Fields!Amount.Value,
> > > > "DataSetName") =Sum(Fields!Amount.Value) /
> > > > First(Fields!Amount.Value, "MatrixName")
> > > >
> > > > --
> > > > This posting is provided "AS IS" with no warranties, and confers
> > > > no
> > > rights.
> > > >
> > > >
> > > > "Kaisa M. Lindahl" <kaisaml@.hotmail.com> wrote in message
> > > > news:enVnqz6BFHA.2260@.TK2MSFTNGP14.phx.gbl...
> > > > > I'm creating my first matrix based report, and find that some
> > > > > things
> > > that
> > > > > work with tables doesn't work the same way with matrix.
> > > > > My resultset comes from an MDX statement. It looks something
> > > > > like this
> > > > >
> > > > > ..............................Registered hours
> > > > ..........Amount
> > > > >
> > > >
> > >
> > .............Total.....................10...............
> > .....
> > > > > 1000
> > > > > Month1....Group
> > > 1..................6.....................600
> > > > > .............Group
> > > > > 2..................4.....................400
> > > > >
> > > > >
> > > >
> > >
> > .............Total.....................12...............
> > .....
> > > > > 1200
> > > > > Month2....Group
> > > 1..................8.....................800
> > > > > .............Group
> > > > > 2..................4.....................400
> > > > >
> > > > > The customer wants to display the values for the months next to
> > > > > each
> > > > other,
> > > > > for each value. Now, I've managed to get this with a matrix,
> > > > > having
> > the
> > > > > [static group] ordered on top. (Thanks to Ohjoo Kwon).
> > > > >
> > > > > BUT one of my columns is supposed to be "Group Result as % of
> > > > > total
> > > > result."
> > > > > Meaning for Group1 in Month1 I need to divide 600 on the Total
> > > > > Amount.
> > > The
> > > > > first row in my result set is always a calculated total for that
> > month.
> > > > So,
> > > > > when using tables, I usually just do =Amount/First(Amount), and
> > > > > that
> > > works
> > > > > like a charm. When I try to do that in a matrix, all I get in
> > > > > return
> > is
> > > > > "100%". So my guess is that in a matrix, I can't use First()
> > > > > the same
> > > way
> > > > as
> > > > > in a table. But how can I do the division? How to divide "Any
> > > > > Row" by
> > > > "First
> > > > > Row"?
> > > > >
> > > > > All help appreciated.
> > > > >
> > > > > Kaisa M. Lindahl
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
>|||Kaisa, in general, leaving the scope out lets RS decide for you.
Generally this will work the way you want.
Chris
Kaisa M. Lindahl wrote:
> OK, thanks to both. I finally figured it out. :)
> I'm still getting confused by when to use what scope. The final
> solution was to change from
> First(Fields!Amount.Value, "Dataset") to First(Fields!Amount.Value,
> "MatrixColumnGroupName").
> Kaisa M. Lindahl
>
> "Chris McGuigan" <chris.mcguigan@.zycko.com> wrote in message
> news:uO5VPAzIFHA.2656@.TK2MSFTNGP09.phx.gbl...
> > If you can group on year or whatever is relevant in your scenario,
> > then within that group, =First(Fields!Amount.Value) should refer to
> > the first value in that group. As Robert said, it's all about scope
> > with aggregate functions. By grouping the data, you are limiting
> > the scope, which is what you want.
> >
> > Chris
> >
> >
> >
> > Kaisa M. Lindahl wrote:
> >
> > > This problem just resurfaced.
> > > Anyone want to give it some thought?
> > >
> > > Is it possible to check for something like
> > > if month = Parameters!FirstPeriod.Value then
> > > 'use this row
> > > end if ?
> > >
> > > Kaisa
> > >
> > > "Kaisa M. Lindahl" <kaisaml@.hotmail.com> wrote in message
> > > news:OACV70qDFHA.1296@.TK2MSFTNGP10.phx.gbl...
> > > > I just realized an error in my original code. What Robert
> > > > suggested
> > > (below)
> > > > works for dividing by the very first row of the result set.
> > > > Unfortunately, I need to divide the right number with the right
> > > > first
> > > row...
> > > > I'll explain
> > > >
> > > > My result looks like this:
> > > > .......................Measures_Amount ...
> > > > ............AllGrps...100
> > > > ............Grp1........30
> > > > 200409...Grp2........30
> > > > ............Grp3.......40
> > > > ............AllGrps....120
> > > > ............Grp1........40
> > > > 200309...Grp2........40
> > > > ............Grp3........40
> > > >
> > > > My report looks someting like this
> > > >
> > > > .............Measures_Amount.....%ofTotalAmt
> > > > Group........200309|200409...200309|200409
> > > > Total..............120|...100........100%|...100%
> > > > Grp1...............40|....30.........33%|....30%
> > > > Grp2...............40|....30.........33%|....30%
> > > > Grp3...............40|....40.........33%|....40%
> > > >
> > > > Today I realized that my statement
> > > > =First(Fields!Measures_Amount.Value)/
> > > > First(Fields!Measures_Amount.Value, "OmsetningHT")
> > > > doesn't work quite as planned. This will divide all rows with
> > > > the very
> > > first
> > > > row, which is the total for 200409. Suddenly all results from
> > > > 200309 are divided by the total for 200409, which is wrong.
> > > >
> > > > So I need a way to divide a group result by the correct total
> > > > in my
> > > matrix.
> > > > The months are organized in a column group.
> > > >
> > > > All help appreciated!
> > > >
> > > > Kaisa M. Lindahl
> > > >
> > > >
> > > > "Robert Bruckner [MSFT]" <robruc@.online.microsoft.com> wrote in
> > > > message news:etV2GOOCFHA.1392@.tk2msftngp13.phx.gbl...
> > > > > You have to provide the "right" scope for the aggregate
> > > > > function. Try
> > > one
> > > > of
> > > > > the two following expressions to divide by the first row:
> > > > > =Sum(Fields!Amount.Value) / First(Fields!Amount.Value,
> > > > > "DataSetName") =Sum(Fields!Amount.Value) /
> > > > > First(Fields!Amount.Value, "MatrixName")
> > > > >
> > > > > --
> > > > > This posting is provided "AS IS" with no warranties, and
> > > > > confers no
> > > > rights.
> > > > >
> > > > >
> > > > > "Kaisa M. Lindahl" <kaisaml@.hotmail.com> wrote in message
> > > > > news:enVnqz6BFHA.2260@.TK2MSFTNGP14.phx.gbl...
> > > > > > I'm creating my first matrix based report, and find that
> > > > > > some things
> > > > that
> > > > > > work with tables doesn't work the same way with matrix.
> > > > > > My resultset comes from an MDX statement. It looks something
> > > > > > like this
> > > > > >
> > > > > > ..............................Registered hours
> > > > > ..........Amount
> > > > > >
> > > > >
> > > >
> > > .............Total.....................10............
> > > ... .....
> > > > > > 1000
> > > > > > Month1....Group
> > > > 1..................6.....................600
> > > > > > .............Group
> > > > > > 2..................4.....................400
> > > > > >
> > > > > >
> > > > >
> > > >
> > > .............Total.....................12............
> > > ... .....
> > > > > > 1200
> > > > > > Month2....Group
> > > > 1..................8.....................800
> > > > > > .............Group
> > > > > > 2..................4.....................400
> > > > > >
> > > > > > The customer wants to display the values for the months
> > > > > > next to each
> > > > > other,
> > > > > > for each value. Now, I've managed to get this with a matrix,
> > > > > > having
> > > the
> > > > > > [static group] ordered on top. (Thanks to Ohjoo Kwon).
> > > > > >
> > > > > > BUT one of my columns is supposed to be "Group Result as %
> > > > > > of total
> > > > > result."
> > > > > > Meaning for Group1 in Month1 I need to divide 600 on the
> > > > > > Total Amount.
> > > > The
> > > > > > first row in my result set is always a calculated total for
> > > > > > that
> > > month.
> > > > > So,
> > > > > > when using tables, I usually just do =Amount/First(Amount),
> > > > > > and that
> > > > works
> > > > > > like a charm. When I try to do that in a matrix, all I get
> > > > > > in return
> > > is
> > > > > > "100%". So my guess is that in a matrix, I can't use First()
> > > > > > the same
> > > > way
> > > > > as
> > > > > > in a table. But how can I do the division? How to divide
> > > > > > "Any Row" by
> > > > > "First
> > > > > > Row"?
> > > > > >
> > > > > > All help appreciated.
> > > > > >
> > > > > > Kaisa M. Lindahl
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> >

Friday, February 24, 2012

Distribution agent insufficient permissions

Hi,

I am trying implement replication and having problem when creating push subscription to an existing transactional replication publication.
The distribution agent is failing to run its job with the error:

Agent message code 14260. You do not have sufficient permission to run this command. Contact your system administrator.

I followed the http://msdn2.microsoft.com/en-us/library/ms151868.aspx article instructions when I set the distribution agent properties

What did I miss?

The following is the step error message:
Date 1/12/2007 2:30:01 PM
Log Job History (105342-DB3\PROD-MOMA-ArchivedTransactions-105337-DEV2-15)

Step ID 2
Server 105342-DB3\PROD
Job Name 105342-DB3\PROD-MOMA-ArchivedTransactions-105337-DEV2-15
Step Name Run agent.
Duration 00:00:00
Sql Severity 0
Sql Message ID 0
Operator Emailed
Operator Net sent
Operator Paged
Retries Attempted 0

Message
2007-01-12 19:30:01.258 Microsoft SQL Server Replication Agent: distrib
2007-01-12 19:30:01.258
2007-01-12 19:30:01.258 The timestamps prepended to the output lines are expressed in terms of UTC time.
2007-01-12 19:30:01.258 User-specified agent parameter values:
-Subscriber 105337-DEV2
-SubscriberDB MOMA
-Publisher 105342-DB3\PROD
-Distributor 105342-DB3\PROD
-DistributorSecurityMode 1
-Publication ArchivedTransactions
-PublisherDB MOMA
-XJOBID 0x65C41EBC553D96439BAF69E4DC3CC823
-XJOBNAME 105342-DB3\PROD-MOMA-ArchivedTransactions-105337-DEV2-15
-XSTEPID 2
-XSUBSYSTEM Distribution
-XSERVER 105342-DB3\PROD
-XCMDLINE 0
-XCancelEventHandle 00000000000006E8
2007-01-12 19:30:01.258 Startup Delay: 214 (msecs)
2007-01-12 19:30:01.477 Connecting to Distributor '105342-DB3\PROD'
2007-01-12 19:30:01.618 Agent message code 14260. You do not have sufficient permission to run this command. Contact your system administrator.

Can you verify the following?

Distribution Agent for a push subscription

The Windows account under which the agent runs is used when it makes connections to the Distributor. This account must:

At minimum be a member of the db_owner fixed database role in the distribution database.

Be a member of the PAL.

Have read permissions on the snapshot share.

Have read permissions on the installation directory of the OLE DB provider for the Subscriber if the subscription is for a non-SQL Server Subscriber.
|||Hi Gray,

Thank you for interesting in my problem.

As I wrote is my first post, I set all required settings ti the distributor Windows account:
it is db_owner of the distribution database|||

Hi Igor,

This error message should not be related to running executables. It is more like SQL permission issue. I would try to turn on SQL profiler to trace the statement in replication SPs. Then we can find out where the 14260 error message is thrown.

Thanks,

Peng

|||Hi Peng,

Thank you for interesting on my problem. It really was related to the SQL rights. Actually, whe I added the distributor user to the db_owner role on the distribution database, the subscription started working properly.

Thank you,
Igor

Distribution Agent - Stored Procedure Error Logging

I know how I can set-up my distribution agent jobs to log them
to a file and up the verbosity of the procedure.
I am in the process of creating snap-shot's of my stored procedures
for replication. The Snapshot agent works just fine, it is
when I use the distribution agent to send it to the subscriber
that it will stop on the first error it finds.
Is there a way to have it run through all the Stored Procedures
so that I don't have to constantly re-create the publication
by removing the first problem sp?
It helps me give the sp's to our developers in one shot
rather than one at a time.
Dave
I think your best bet is to create a separate publication for each stored
procedure. This way the only procs which fail to be replicated are the
problem ones - the remainder will be replicated.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"David Gresham" <gresham@.panix.com> wrote in message
news:d62hq1$mar$1@.reader1.panix.com...
> I know how I can set-up my distribution agent jobs to log them
> to a file and up the verbosity of the procedure.
> I am in the process of creating snap-shot's of my stored procedures
> for replication. The Snapshot agent works just fine, it is
> when I use the distribution agent to send it to the subscriber
> that it will stop on the first error it finds.
>
> Is there a way to have it run through all the Stored Procedures
> so that I don't have to constantly re-create the publication
> by removing the first problem sp?
> It helps me give the sp's to our developers in one shot
> rather than one at a time.
>
> Dave
>

Distribution Agent - Replication Monitor warning

Hi,

I am replicating a large table with a number of indexes. During the initialisation phase (creating the indexes at the subscriber), I am seing the following error/warning in Replication monitor. When the initialisation is complete the error warnings dissapear.

The replication agent has not logged a progress message in 10 minutes. This might indicate an unresponsive agent or high system activity. Verify that records are being replicated to the destination and that connections to the Subscriber, Publisher, and Distributor are still active.

Is there a way to increase the 10 minute time-limit?

Thanks,
Priyanga

Hi Priyanga,

You can use the -KeepAliveMessage parameter of the distribution agent to specify a larger time interval for logging the "agent suspect" messages. However, I am a bit hesitant to recommend that you simply increase the time interval in general since you would probably want to be notified that the distribution agent may be stalled in a more timely manner when it is delivering incremental changes. On the other hand, delivery of snapshot is arguably a rare enough occurrence that the "agent suspect" messages should not become a significant source of annoyance.

In truth, the following factors had conspired to make the "agent suspect" messages almost unavoidable when delivering a large snapshot:

1) BCP API does not allow the distribution agent to log a progress message until every "BcpBatchSize" number of rows have been bulk-loaded into a subscriber table
2) We use a large "BcpBatchSize" (2^31 - delta) as the default "BcpBatchSize" in SQL2005 so the distribution agent can more readily meet the minimally-logged bulk-load requirements.
3) The time required to create an index on a large table probably exceeds the default -KeepAliveMessageInterval

Based on 1) and 2) above, distribution agent will mostly not be able to log a progress message in-between a bulk-load operation;and if the amount of data that needs to be bulk-loaded is large, the distribution agent will likely not be able to finish the bulk-load operation within the default -KeepAliveMessageInterval.

HTH

-Raymond

Sunday, February 19, 2012

distributing a database and creating a new user

Hi!
I'm new to trans-SQL. I wounder how I can add an user to newly created
database?
I've created a window-application that is using a SQL-database for reading
and storing data.
When I now want to distribute my application I also need to distrubute my
database.
Is the best way of distributing a database through trans-SQL?
Or should I create a new database on my localhost and distribute a backup?
the code I've so far is...
USE master
GO
CREATE DATABASE myTestDB
ON
(NAME = myTestDB_dat,
FILENAME= 'c:\program files\microsoft sql server\mssql\data\myTestDBdat.mdf'
,
SIZE = 10,
MAXSIZE = 50,
FILEGROWTH = 5)
GO
I would like to have an user called "testuser" with password "test"
please help.
Thanks in advanced
Best regards
- Hans -
--
(Have fun programming with ... C#)1. you can add a user using the sp_adduser stored proc
sp_adduser [ @.loginame = ] 'login'
[ , [ @.name_in_db = ] 'user' ]
[ , [ @.grpname = ] 'group' ]
2. or you use an exisiting windows nt account using the so addlogin
sp_adduser [ @.loginame = ] 'login'
[ , [ @.name_in_db = ] 'user' ]
[ , [ @.grpname = ] 'group' ]
3. you can also add a "users" table which contains userinformations such
as userid, name, lastname,etc and the password which you can be hashed using
md5 or sha1 technology of the.net .
In this way you can easily add, remove user or changed their password.
you can make the application or a stored proc to verify if the password is
corerct.
in this approach you will be using a single account to connect to sql server
.
will it will depends on you computing needs
hope it helps
"Hans [DiaGraphIT]" wrote:

> Hi!
> I'm new to trans-SQL. I wounder how I can add an user to newly created
> database?
> I've created a window-application that is using a SQL-database for reading
> and storing data.
> When I now want to distribute my application I also need to distrubute my
> database.
> Is the best way of distributing a database through trans-SQL?
> Or should I create a new database on my localhost and distribute a backup?
> the code I've so far is...
> USE master
> GO
> CREATE DATABASE myTestDB
> ON
> (NAME = myTestDB_dat,
> FILENAME= 'c:\program files\microsoft sql server\mssql\data\myTestDBdat.md
f',
> SIZE = 10,
> MAXSIZE = 50,
> FILEGROWTH = 5)
> GO
> I would like to have an user called "testuser" with password "test"
> please help.
> Thanks in advanced
> --
> Best regards
> - Hans -
> --
> (Have fun programming with ... C#)|||sorry got a little messed up. let me correct my self
for sql user
1. sp_addlogin
Creates a new Microsoft? SQL Server? login that allows a user to connect
to
an instance of SQL Server using SQL Server Authentication.
Syntax
sp_addlogin [ @.loginame = ] 'login'
[ , [ @.passwd = ] 'password' ]
[ , [ @.defdb = ] 'database' ]
[ , [ @.deflanguage = ] 'language' ]
[ , [ @.sid = ] sid ]
[ , [ @.encryptopt = ] 'encryption_option' ]
2. sp_grantlogin for windows account
sp_grantlogin [@.loginame =] 'login'
3. to allow SQL users to use the database you can use
sp_adduser/sp_grantdbaccess
4. to allow Nt users you can use
sp_grantdbaccess
"jose g. de jesus jr mcp, mcdba" wrote:
> 1. you can add a user using the sp_adduser stored proc
> sp_adduser [ @.loginame = ] 'login'
> [ , [ @.name_in_db = ] 'user' ]
> [ , [ @.grpname = ] 'group' ]
> 2. or you use an exisiting windows nt account using the so addlogin
> sp_adduser [ @.loginame = ] 'login'
> [ , [ @.name_in_db = ] 'user' ]
> [ , [ @.grpname = ] 'group' ]
> 3. you can also add a "users" table which contains userinformations such
> as userid, name, lastname,etc and the password which you can be hashed usi
ng
> md5 or sha1 technology of the.net .
> In this way you can easily add, remove user or changed their passwo
rd.
> you can make the application or a stored proc to verify if the password is
> corerct.
> in this approach you will be using a single account to connect to sql serv
er.
> will it will depends on you computing needs
> hope it helps
>
> "Hans [DiaGraphIT]" wrote:
>|||this made sense... Ill try it out first thing tomorrow morning
thank you
Best regards
- Hans -
--
(Have fun programming with ... C#)
"jose g. de jesus jr mcp, mcdba" wrote:
> sorry got a little messed up. let me correct my self
> for sql user
> 1. sp_addlogin
> Creates a new Microsoft? SQL Server? login that allows a user to connec
t to
> an instance of SQL Server using SQL Server Authentication.
> Syntax
> sp_addlogin [ @.loginame = ] 'login'
> [ , [ @.passwd = ] 'password' ]
> [ , [ @.defdb = ] 'database' ]
> [ , [ @.deflanguage = ] 'language' ]
> [ , [ @.sid = ] sid ]
> [ , [ @.encryptopt = ] 'encryption_option' ]
> 2. sp_grantlogin for windows account
> sp_grantlogin [@.loginame =] 'login'
> 3. to allow SQL users to use the database you can use
> sp_adduser/sp_grantdbaccess
> 4. to allow Nt users you can use
> sp_grantdbaccess
>
> "jose g. de jesus jr mcp, mcdba" wrote:
>