Showing posts with label switch. Show all posts
Showing posts with label switch. Show all posts

Tuesday, March 20, 2012

quick switch question

hi there
is it possible to have 2 conditions within a switch expression like the
following
=switch(Fields!ReferrerDept.Value = 56, "x Branch",
(Fields!ReferrerDept.Value = 22 and Fields!ReferrerName.Value = 'name'),
"Self Generated - Name",
true, Nothing)
ThanksIn what language? Your code looks very VBish to me (looks like it came
out of a Reporting Services chunk of code actually). In T-SQL, these
kind of conditional expressions are done with a CASE
<http://msdn.microsoft.com/library/e..._ca-co_5t9v.asp>
functions, and yes, as long as it evaluates to a boolean expression,
your individual case conditions can be pretty much as complex as you
like, and you can nest CASE functions, but your result expressions in
each conditional branch need to evaluate to the same datatype.
For example, while I don't really follow what your logic is trying to
achieve, in T-SQL it would be something like: (untested)
SELECT
CASE
WHEN (ReferrerDept = 56) THEN 'x Branch'
WHEN (ReferrerDept = 22 AND ReferrerName = 'name') THEN 'Self
Generated - Name'
ELSE null
END as [MyCol]
FROM MyTable
*mike hodgson*
blog: http://sqlnerd.blogspot.com
Tango wrote:

>hi there
>is it possible to have 2 conditions within a switch expression like the
>following
>=switch(Fields!ReferrerDept.Value = 56, "x Branch",
>(Fields!ReferrerDept.Value = 22 and Fields!ReferrerName.Value = 'name'),
>"Self Generated - Name",
>true, Nothing)
>Thanks
>|||thanks Mike
"Mike Hodgson" wrote:

> In what language? Your code looks very VBish to me (looks like it came
> out of a Reporting Services chunk of code actually). In T-SQL, these
> kind of conditional expressions are done with a CASE
> <http://msdn.microsoft.com/library/e..._ca-co_5t9v.asp>
> functions, and yes, as long as it evaluates to a boolean expression,
> your individual case conditions can be pretty much as complex as you
> like, and you can nest CASE functions, but your result expressions in
> each conditional branch need to evaluate to the same datatype.
> For example, while I don't really follow what your logic is trying to
> achieve, in T-SQL it would be something like: (untested)
> SELECT
> CASE
> WHEN (ReferrerDept = 56) THEN 'x Branch'
> WHEN (ReferrerDept = 22 AND ReferrerName = 'name') THEN 'Self
> Generated - Name'
> ELSE null
> END as [MyCol]
> FROM MyTable
> --
> *mike hodgson*
> blog: http://sqlnerd.blogspot.com
>
> Tango wrote:
>
>

Saturday, February 25, 2012

Quick and Easy question

I want to present an option to one of my clients to
switch from Exchange to an SQL database.
They are using Public folder for a lot and we get blamed
everytime something gets deleted by a user. They do have
a lot of data in PF. I also know that when something goes
awol and we have to restore the PF by dismounting PF and
taking everyone down for however long.
My questions are these:
How quickly can you restore SQL. Do you have to take the
whole database down to restore; can you restore just
certain tables, data, etc ..; can the users still work
away while restoring any portion of the database?
Thanks for all the help!!
KevinA database is unavailable while it is being restored (although it can be in
use while being backed-up). You can control the placement of individual
tables and indexes on filegroups and then backup or restore those filegroups
individually. You can also do a point-in-time restore which allows you to
roll back to a point before any data loss or corruption occurred.
However, you seem to be asking the wrong question. I don't know Exchange but
in SQLServer the solution to your problem is to implement user/object based
permissions so as to prevent users from deleting data that they are not
authorized to delete.
--
David Portas
SQL Server MVP
--