Sunday, March 11, 2012
can it be overdone with check statements?
I would assume most columns in a db would have a known valid range of values
that it makes sense for the business logics. For example, most counting
columns shouldn't have negative value even though it makes some mathetical
sense but high level application code typically doesn't handle it well. So
I'm wondering if experienced db designers would think it's worth adding a
huge check constraint to make sure all values entered into the table are
within the valid (or expected) range. thank you very much.I'm a great fan of CHECK constraints!
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Zeng" <Zeng5000@.hotmail.com> wrote in message news:%23BEpd4AfFHA.640@.tk2msftngp13.phx.gbl...
> Hi,
> I would assume most columns in a db would have a known valid range of values
> that it makes sense for the business logics. For example, most counting
> columns shouldn't have negative value even though it makes some mathetical
> sense but high level application code typically doesn't handle it well. So
> I'm wondering if experienced db designers would think it's worth adding a
> huge check constraint to make sure all values entered into the table are
> within the valid (or expected) range. thank you very much.
>|||Just like Tibor, I am a great fan of Check constraints and use them
generously. However you can probably overdo anything...The reason I use so
many check constraints is that it protects the database against faulty code,
and users who bypass the application using Excel, QA, SEM or any of the
other tools easily obtainable.
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Zeng" <Zeng5000@.hotmail.com> wrote in message
news:%23BEpd4AfFHA.640@.tk2msftngp13.phx.gbl...
> Hi,
> I would assume most columns in a db would have a known valid range of
> values
> that it makes sense for the business logics. For example, most counting
> columns shouldn't have negative value even though it makes some mathetical
> sense but high level application code typically doesn't handle it well.
> So
> I'm wondering if experienced db designers would think it's worth adding a
> huge check constraint to make sure all values entered into the table are
> within the valid (or expected) range. thank you very much.
>|||is there any advantage of having one for each isolated column in a table or
a huge one per table (with the use of AND and OR operator)?
Thanks!
"Wayne Snyder" <wayne.nospam.snyder@.mariner-usa.com> wrote in message
news:uKtOgJCfFHA.3448@.TK2MSFTNGP12.phx.gbl...
> Just like Tibor, I am a great fan of Check constraints and use them
> generously. However you can probably overdo anything...The reason I use so
> many check constraints is that it protects the database against faulty
code,
> and users who bypass the application using Excel, QA, SEM or any of the
> other tools easily obtainable.
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "Zeng" <Zeng5000@.hotmail.com> wrote in message
> news:%23BEpd4AfFHA.640@.tk2msftngp13.phx.gbl...
> > Hi,
> >
> > I would assume most columns in a db would have a known valid range of
> > values
> > that it makes sense for the business logics. For example, most counting
> > columns shouldn't have negative value even though it makes some
mathetical
> > sense but high level application code typically doesn't handle it well.
> > So
> > I'm wondering if experienced db designers would think it's worth adding
a
> > huge check constraint to make sure all values entered into the table are
> > within the valid (or expected) range. thank you very much.
> >
> >
>
Friday, February 24, 2012
Can I Turn off Auto Execution of Report when all parameters have default values?
My situation....
I deploy a report in Report Server. Ther report has 5-10 parameters. When I design the report, I supply a default value for each parameter, similiar to the "Add a select all option" tutorials.
So I end up with defaults like "Select a Project Manager", "Select a Fiscal Year", etc... I use dynamic queries to read the parameters and insert the appropriate logic into the where string of my main dataset. If the user selects a value from my parameter lists, I append a clause to the SQL string, if they choose the default option, I ignore the parameter, and that effectively returns all of the records (like Select * from ....)
My Issue...
When I provide a default paramater for ALL of the parameters available, the report auto-executes when the user picks it from the folder, and isn;t given the opportunity to refine the default criteria I have provided.
My Question....
Is there any way to turn the autoexecution off?
Thanks for any help...
There is no method to turn off the auto execution of the report if all parameters have default values.
As you have probable already found out, you can populate all but one of the parameters to get the result you desire. But that makes the user have to supply a value of the parameter.
Sunday, February 19, 2012
Can I set a default range for the identity values for merge replication?
Hello,
We have a couple of tables that can have quite a bit of data each day prior to replication. Can we increase the default values for a table for each subscription? For example we have a table called table1 and on the sqlexpress client they could enter in 10000 rows a day, on table2 it's just 100 rows a day. How can we increase the values to where we do not get the error for table1 stating that the insert failed because it conflicted with the identity range check constraint. Thanks in advance.
Hi, John
If I understand correctly, you actually want to set different identityrange from different article. For example, table1 identity range is 10,000 and table2 with identity range is 1,000. You can set it through sp_addmergearticle with control values of @.identityrangemanagementoption, @.pub_identity_range, and @.identity_range.
BTW, you are not allowed to set different identity range for different subscriptions which subscribe to the same publication.
Hope these information will help.
Thanks
Yunjing
Thursday, February 16, 2012
Can I Restrict Values in a Parameter Dropdown based on the User?
parameters. One of them is Department Id. For some users, I want them to be
able to only run the report against their own department id but still be able
to select any of the values for the other parameters. Other users will be
able to select any value for department id and the other parameters.
I can figure out how to write the query to populate the Department ID
dropdown but cannot figure how to access the current userid programatically.
Is there a way to access the user ID in order to restrict the values in a
parameter dropdown?
I'm using RS2003 with SQL Server 2000. Any ideas are welcome!
Thanks,
LizThis is really quite easy. There is a global parameter called User!UserID it
returns the domain and user ID of the user running the report. To see the
format of this create a report with a single textbox (no datasets). Set the
text box to an expression and set it to this (case sensitive):
=User!UserID
You might want to strip the domain off.
OK, the second part of this is that you need to realize that query parameter
and report parameter are two different things. You do not have to have a
query parameter mapped to a report parameter. It can be mapped to an
expression instead.
So, let's say you have this query
Select department from mydepartmentlist where userID = @.UserID
RS will create a report parameter for this called UserID. You will not use
it. You will delete it. Instead in the dataset tab click on the ... go to
the parameters tab, click on the dropdown box where the query parameter is
being mapped to report parameter and pick expression instead. Then set it to
the expression above. If you don't want the domain then use something like
this:
=mid(User!UserID, LengthToCutOffTheFront)
Of course for all of this to work you need a table somewhere that maps the
userid to the departments.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Liz" <Liz@.discussions.microsoft.com> wrote in message
news:5A54A060-B916-4BB4-AE03-9AF8302601A7@.microsoft.com...
> I've got a puzzler here. I have a report with 4 different dropdown lists
> for
> parameters. One of them is Department Id. For some users, I want them to
> be
> able to only run the report against their own department id but still be
> able
> to select any of the values for the other parameters. Other users will be
> able to select any value for department id and the other parameters.
> I can figure out how to write the query to populate the Department ID
> dropdown but cannot figure how to access the current userid
> programatically.
> Is there a way to access the user ID in order to restrict the values in a
> parameter dropdown?
> I'm using RS2003 with SQL Server 2000. Any ideas are welcome!
> Thanks,
> Liz
>|||Thanks! That's very helpful and I've already succeeded at stripping off the
domain name.
I know you can pass parameter values through the URL and query string to the
report. If I wanted to pass the department ID from the calling application
to populate the dropdown, is there a way to pass that one parameter value and
let the user select the other three?
Thanks for your help,
Liz
"Bruce L-C [MVP]" wrote:
> This is really quite easy. There is a global parameter called User!UserID it
> returns the domain and user ID of the user running the report. To see the
> format of this create a report with a single textbox (no datasets). Set the
> text box to an expression and set it to this (case sensitive):
> =User!UserID
> You might want to strip the domain off.
> OK, the second part of this is that you need to realize that query parameter
> and report parameter are two different things. You do not have to have a
> query parameter mapped to a report parameter. It can be mapped to an
> expression instead.
> So, let's say you have this query
> Select department from mydepartmentlist where userID = @.UserID
> RS will create a report parameter for this called UserID. You will not use
> it. You will delete it. Instead in the dataset tab click on the ... go to
> the parameters tab, click on the dropdown box where the query parameter is
> being mapped to report parameter and pick expression instead. Then set it to
> the expression above. If you don't want the domain then use something like
> this:
> =mid(User!UserID, LengthToCutOffTheFront)
> Of course for all of this to work you need a table somewhere that maps the
> userid to the departments.
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "Liz" <Liz@.discussions.microsoft.com> wrote in message
> news:5A54A060-B916-4BB4-AE03-9AF8302601A7@.microsoft.com...
> > I've got a puzzler here. I have a report with 4 different dropdown lists
> > for
> > parameters. One of them is Department Id. For some users, I want them to
> > be
> > able to only run the report against their own department id but still be
> > able
> > to select any of the values for the other parameters. Other users will be
> > able to select any value for department id and the other parameters.
> >
> > I can figure out how to write the query to populate the Department ID
> > dropdown but cannot figure how to access the current userid
> > programatically.
> > Is there a way to access the user ID in order to restrict the values in a
> > parameter dropdown?
> >
> > I'm using RS2003 with SQL Server 2000. Any ideas are welcome!
> >
> > Thanks,
> > Liz
> >
> >
>
>|||Sure. You have have a hidden parameter that gets filled in by the calling
application. The user only selects from the list you provide. Look at hidden
parameters in the books online.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Liz" <Liz@.discussions.microsoft.com> wrote in message
news:D0F372BF-DA85-4BD6-A01C-ED2708F14BAC@.microsoft.com...
> Thanks! That's very helpful and I've already succeeded at stripping off
> the
> domain name.
> I know you can pass parameter values through the URL and query string to
> the
> report. If I wanted to pass the department ID from the calling
> application
> to populate the dropdown, is there a way to pass that one parameter value
> and
> let the user select the other three?
> Thanks for your help,
> Liz
>
> "Bruce L-C [MVP]" wrote:
>> This is really quite easy. There is a global parameter called User!UserID
>> it
>> returns the domain and user ID of the user running the report. To see the
>> format of this create a report with a single textbox (no datasets). Set
>> the
>> text box to an expression and set it to this (case sensitive):
>> =User!UserID
>> You might want to strip the domain off.
>> OK, the second part of this is that you need to realize that query
>> parameter
>> and report parameter are two different things. You do not have to have a
>> query parameter mapped to a report parameter. It can be mapped to an
>> expression instead.
>> So, let's say you have this query
>> Select department from mydepartmentlist where userID = @.UserID
>> RS will create a report parameter for this called UserID. You will not
>> use
>> it. You will delete it. Instead in the dataset tab click on the ... go to
>> the parameters tab, click on the dropdown box where the query parameter
>> is
>> being mapped to report parameter and pick expression instead. Then set it
>> to
>> the expression above. If you don't want the domain then use something
>> like
>> this:
>> =mid(User!UserID, LengthToCutOffTheFront)
>> Of course for all of this to work you need a table somewhere that maps
>> the
>> userid to the departments.
>>
>> --
>> Bruce Loehle-Conger
>> MVP SQL Server Reporting Services
>> "Liz" <Liz@.discussions.microsoft.com> wrote in message
>> news:5A54A060-B916-4BB4-AE03-9AF8302601A7@.microsoft.com...
>> > I've got a puzzler here. I have a report with 4 different dropdown
>> > lists
>> > for
>> > parameters. One of them is Department Id. For some users, I want them
>> > to
>> > be
>> > able to only run the report against their own department id but still
>> > be
>> > able
>> > to select any of the values for the other parameters. Other users will
>> > be
>> > able to select any value for department id and the other parameters.
>> >
>> > I can figure out how to write the query to populate the Department ID
>> > dropdown but cannot figure how to access the current userid
>> > programatically.
>> > Is there a way to access the user ID in order to restrict the values in
>> > a
>> > parameter dropdown?
>> >
>> > I'm using RS2003 with SQL Server 2000. Any ideas are welcome!
>> >
>> > Thanks,
>> > Liz
>> >
>> >
>>