Showing posts with label view. Show all posts
Showing posts with label view. Show all posts

Tuesday, March 27, 2012

Can we create composite logical key in data source view?

Hi, all,

Just found that I need to create a composite logical key consisting of a few columns in data source view in order to uniquely identify each row of record for the table in data source view, but then found that I am not able to create this kind of logical key? Is there any ways for us to create such a compoiste logical key in the data source view?

Thanks in advance and I am very much looking forward to hearing from you for your kind and helpful advices.

With best regards,

Yours sincerely,

You can create composite logical keys in the DSV, just multi-select columns, right click, and mark as logical key. However, if an existing physical key (i.e. a key reported by the relational source), then the DSV will not allow you to create any logical key.|||

Hi,

Thanks a lot.

WIth best regards,

Yours sincerely,

Can we control the privilege of Drilling down?

How can we control the privilege of Drilling down?

For example:

There are for sale area of a company.

The manager of the company can view the total sale report of whole company, and view the individual sales report of the four area. The sales can view the total sale report of whole company, but they can only drill down the area of himself,they can not drill down the other area .

How can I do that?

Hi,
you can perform check of privilege of drilling down by Code in (ReportProperties).
For example (in Properties):
[Row].Visibility = Code.MyFunction
where MyFunction check if the Current user has necessary privilege to see selected row.

Best Regards

Can we contol the privilege of Drilling down

How can we contol the privilege of Drilling down?
For example:
There are for sale area of a company.
The manager of the company can view the total sale reoprt of whole company,
and view the individual sales report of the four area. The sales can view
the total sale reoprt of whole company, but the can only drill down the area
of themself, they can not drill down the other area .
How can I do that?Can any one help me!
"ad" <ad@.wfes.tcc.edu.tw> ¼¶¼g©ó¶l¥ó·s»D
:O3OBudyXFHA.3040@.TK2MSFTNGP14.phx.gbl...
> How can we contol the privilege of Drilling down?
> For example:
> There are for sale area of a company.
> The manager of the company can view the total sale reoprt of whole
company,
> and view the individual sales report of the four area. The sales can view
> the total sale reoprt of whole company, but the can only drill down the
area
> of themself, they can not drill down the other area .
> How can I do that?
>sql

Sunday, March 25, 2012

Can views be used in query builder?

I tried it but got an invalid object error. I then copied and pasted the sql statement contained in the view but it doesn't run correctly inside query builder and only shows 1 valid row, and a 2nd row that's blank the the first column and has a number 1 in the second column. The view runs correctly in SQL Server Management Studio Express.

How about wrapping the view inside a stored procedure?

|||

Stored procedures can't be used in query builder either. All I can do is put in a dummy SQL statement (like Select 1 as column1, 2 as whatever) and then change it to a stored procedure later when I have access to the "data" tab in [Design].

That doesn't seem right but is the only way I can figure out how to do it.

can view reports created in RS after upgrading to RS sp1?

Hi,
My server is currently running Reporting Services. I want to upgrade it
to reporting services sp1 or sp2. I wanna know after upgrading it to
sp1, will I will be able to view my older reports which is created
using reporting services?No problem. I suggest sp2. Also, upgrade your designer as well.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"sheerin" <susheelkaur@.gmail.com> wrote in message
news:1141189981.337655.34260@.e56g2000cwe.googlegroups.com...
> Hi,
> My server is currently running Reporting Services. I want to upgrade it
> to reporting services sp1 or sp2. I wanna know after upgrading it to
> sp1, will I will be able to view my older reports which is created
> using reporting services?
>

can view be dynamically filtered like an MSAccess query?

In MSAccess you can dynamically filter a query by adding square brackets [ ]
to the criteria section and a prompt inside the brackets [enter filter code]
.
Then you can open the query directly and be prompted for a filter. I tried
this in the view without any success.
I was approached today by an End user who uses an Access ADP to interface
with our sql server. The user needs to pull/look at data from a large
table, and currently there is no mechanism for filtering the respective tabl
e
in the Access ADP. Since several users are using the same ADP, I don't want
to modify it. I was thinking of creating a view that could be opened from
the ADP. But rather than having the user call me everytime he needs to
change the criteria, is there a way to make the view dynamic?
Thanks,
RichRich,
You can use an inline table-valued function. You can not pass parameters to
a view.
Inline User-Defined Functions
http://msdn.microsoft.com/library/d...>
_08_73lf.asp
AMB
"Rich" wrote:

> In MSAccess you can dynamically filter a query by adding square brackets [
]
> to the criteria section and a prompt inside the brackets [enter filter cod
e].
> Then you can open the query directly and be prompted for a filter. I tri
ed
> this in the view without any success.
> I was approached today by an End user who uses an Access ADP to interface
> with our sql server. The user needs to pull/look at data from a large
> table, and currently there is no mechanism for filtering the respective ta
ble
> in the Access ADP. Since several users are using the same ADP, I don't wa
nt
> to modify it. I was thinking of creating a view that could be opened from
> the ADP. But rather than having the user call me everytime he needs to
> change the criteria, is there a way to make the view dynamic?
> Thanks,
> Rich|||Thanks - very . I will give this a shot. The only thing is that - afte
r
reading the article - it looks like the user needs to write a sql statement.
If the user is using an Access ADP - where does he write the statement to us
e
the inline function? In the article it looked like the user had QA on his
desktop.
"Alejandro Mesa" wrote:
> Rich,
> You can use an inline table-valued function. You can not pass parameters t
o
> a view.
> Inline User-Defined Functions
> http://msdn.microsoft.com/library/d...
es_08_73lf.asp
>
> AMB
> "Rich" wrote:
>|||I figured it out. The function will show up in the user interface. The use
r
can invoke the function the same way as a query in MSAccess and will be
prompted for input. Very . Thanks again for the suggestion.
"Rich" wrote:
> Thanks - very . I will give this a shot. The only thing is that - af
ter
> reading the article - it looks like the user needs to write a sql statemen
t.
> If the user is using an Access ADP - where does he write the statement to
use
> the inline function? In the article it looked like the user had QA on his
> desktop.
> "Alejandro Mesa" wrote:
>

Can view accept parameters

Hi All ,
i wonder if a view can accept parameters becoz i only
want to show certain columns based on user's input.
if it's not possible, could i know is there other
alternative as to accept both the user's input as well as
restrict the column to be displayed as readonly
thks & rdgsWhat version are you running? Please always state that information.
If you are using SQL Server 2000, you can create a table valued function
that can be used EXACTLY like a view which accepts parameters. Please read
about CREATE FUNCTION in the Books Online.
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"maxzsim" <anonymous@.discussions.microsoft.com> wrote in message
news:056c01c47aae$ea2814d0$a501280a@.phx.gbl...
> Hi All ,
> i wonder if a view can accept parameters becoz i only
> want to show certain columns based on user's input.
> if it's not possible, could i know is there other
> alternative as to accept both the user's input as well as
> restrict the column to be displayed as readonly
> thks & rdgs|||Hi Kalen ,
my appologies ..
btw i am using SQL 7.0 , is this possible then ?
thks
>--Original Message--
>What version are you running? Please always state that
information.
>If you are using SQL Server 2000, you can create a table
valued function
>that can be used EXACTLY like a view which accepts
parameters. Please read
>about CREATE FUNCTION in the Books Online.
>--
>HTH
>--
>Kalen Delaney
>SQL Server MVP
>www.SolidQualityLearning.com
>
>"maxzsim" <anonymous@.discussions.microsoft.com> wrote in
message
>news:056c01c47aae$ea2814d0$a501280a@.phx.gbl...
as[vbcol=seagreen]
>
>.
>|||No. In the relational model, a view is just like a table and a table doesn't
accept parameters.
In-line table values functions is what some call "a view that accepts parame
ters" but that feature was added
in 2000. Can you use a stored procedure instead?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"maxzsim" <anonymous@.discussions.microsoft.com> wrote in message
news:042d01c47ab0$eb6bcd80$a301280a@.phx.gbl...[vbcol=seagreen]
> Hi Kalen ,
> my appologies ..
> btw i am using SQL 7.0 , is this possible then ?
> thks
> information.
> valued function
> parameters. Please read
> message
> assql

Can view accept parameters

Hi All ,
i wonder if a view can accept parameters becoz i only
want to show certain columns based on user's input.
if it's not possible, could i know is there other
alternative as to accept both the user's input as well as
restrict the column to be displayed as readonly
thks & rdgs
What version are you running? Please always state that information.
If you are using SQL Server 2000, you can create a table valued function
that can be used EXACTLY like a view which accepts parameters. Please read
about CREATE FUNCTION in the Books Online.
HTH
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"maxzsim" <anonymous@.discussions.microsoft.com> wrote in message
news:056c01c47aae$ea2814d0$a501280a@.phx.gbl...
> Hi All ,
> i wonder if a view can accept parameters becoz i only
> want to show certain columns based on user's input.
> if it's not possible, could i know is there other
> alternative as to accept both the user's input as well as
> restrict the column to be displayed as readonly
> thks & rdgs
|||Hi Kalen ,
my appologies ..
btw i am using SQL 7.0 , is this possible then ?
thks
>--Original Message--
>What version are you running? Please always state that
information.
>If you are using SQL Server 2000, you can create a table
valued function
>that can be used EXACTLY like a view which accepts
parameters. Please read
>about CREATE FUNCTION in the Books Online.
>--
>HTH
>--
>Kalen Delaney
>SQL Server MVP
>www.SolidQualityLearning.com
>
>"maxzsim" <anonymous@.discussions.microsoft.com> wrote in
message[vbcol=seagreen]
>news:056c01c47aae$ea2814d0$a501280a@.phx.gbl...
as
>
>.
>
|||No. In the relational model, a view is just like a table and a table doesn't accept parameters.
In-line table values functions is what some call "a view that accepts parameters" but that feature was added
in 2000. Can you use a stored procedure instead?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"maxzsim" <anonymous@.discussions.microsoft.com> wrote in message
news:042d01c47ab0$eb6bcd80$a301280a@.phx.gbl...[vbcol=seagreen]
> Hi Kalen ,
> my appologies ..
> btw i am using SQL 7.0 , is this possible then ?
> thks
> information.
> valued function
> parameters. Please read
> message
> as

Thursday, March 22, 2012

Can view accept parameters

Hi All ,
i wonder if a view can accept parameters becoz i only
want to show certain columns based on user's input.
if it's not possible, could i know is there other
alternative as to accept both the user's input as well as
restrict the column to be displayed as readonly
thks & rdgsWhat version are you running? Please always state that information.
If you are using SQL Server 2000, you can create a table valued function
that can be used EXACTLY like a view which accepts parameters. Please read
about CREATE FUNCTION in the Books Online.
--
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"maxzsim" <anonymous@.discussions.microsoft.com> wrote in message
news:056c01c47aae$ea2814d0$a501280a@.phx.gbl...
> Hi All ,
> i wonder if a view can accept parameters becoz i only
> want to show certain columns based on user's input.
> if it's not possible, could i know is there other
> alternative as to accept both the user's input as well as
> restrict the column to be displayed as readonly
> thks & rdgs|||Hi Kalen ,
my appologies ..
btw i am using SQL 7.0 , is this possible then ?
thks
>--Original Message--
>What version are you running? Please always state that
information.
>If you are using SQL Server 2000, you can create a table
valued function
>that can be used EXACTLY like a view which accepts
parameters. Please read
>about CREATE FUNCTION in the Books Online.
>--
>HTH
>--
>Kalen Delaney
>SQL Server MVP
>www.SolidQualityLearning.com
>
>"maxzsim" <anonymous@.discussions.microsoft.com> wrote in
message
>news:056c01c47aae$ea2814d0$a501280a@.phx.gbl...
>> Hi All ,
>> i wonder if a view can accept parameters becoz i only
>> want to show certain columns based on user's input.
>> if it's not possible, could i know is there other
>> alternative as to accept both the user's input as well
as
>> restrict the column to be displayed as readonly
>> thks & rdgs
>
>.
>|||No. In the relational model, a view is just like a table and a table doesn't accept parameters.
In-line table values functions is what some call "a view that accepts parameters" but that feature was added
in 2000. Can you use a stored procedure instead?
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"maxzsim" <anonymous@.discussions.microsoft.com> wrote in message
news:042d01c47ab0$eb6bcd80$a301280a@.phx.gbl...
> Hi Kalen ,
> my appologies ..
> btw i am using SQL 7.0 , is this possible then ?
> thks
> >--Original Message--
> >What version are you running? Please always state that
> information.
> >
> >If you are using SQL Server 2000, you can create a table
> valued function
> >that can be used EXACTLY like a view which accepts
> parameters. Please read
> >about CREATE FUNCTION in the Books Online.
> >
> >--
> >HTH
> >--
> >Kalen Delaney
> >SQL Server MVP
> >www.SolidQualityLearning.com
> >
> >
> >"maxzsim" <anonymous@.discussions.microsoft.com> wrote in
> message
> >news:056c01c47aae$ea2814d0$a501280a@.phx.gbl...
> >> Hi All ,
> >>
> >> i wonder if a view can accept parameters becoz i only
> >> want to show certain columns based on user's input.
> >>
> >> if it's not possible, could i know is there other
> >> alternative as to accept both the user's input as well
> as
> >> restrict the column to be displayed as readonly
> >>
> >> thks & rdgs
> >
> >
> >.
> >

Can user view objects they only have select permission on?

I have a user that belongs to a role. This role only has select permissions
on 10 views. When I log in as this user via Management Studio I cannot see
the views however I can execute queries against them.
On another server that I did not setup, that I'm supposed to be mimicking
the same security, this same user can see the views.
Any ideas what the difference is?
Thanks!Here's the commands that I'm executing in order:
CREATE ROLE [Customers_ROLE] Authorization dbo
CREATE SCHEMA [Customers_Schema] AUTHORIZATION [Customers_Role] Deny
View
Definition to [Customers_Role]
exec sp_adduser 'phenson', 'phenson', [Customers_Role]
GRANT SELECT ON [dbo].[PT_VIEW] TO [Customers_Role]
When I log in as phenson I do not see PT_View but I can query on it. I need
to be able to see it.
"SpankyATL" wrote:

> I have a user that belongs to a role. This role only has select permissio
ns
> on 10 views. When I log in as this user via Management Studio I cannot se
e
> the views however I can execute queries against them.
> On another server that I did not setup, that I'm supposed to be mimicking
> the same security, this same user can see the views.
> Any ideas what the difference is?
> Thanks!|||I thought I'd answer my own question for those of you who come across this
some day. I need to remove the "Deny View Definition" portion and that took
care of it. The user was able to see that view and execute it but could not
see the script.
"SpankyATL" wrote:
[vbcol=seagreen]
> Here's the commands that I'm executing in order:
> CREATE ROLE [Customers_ROLE] Authorization dbo
> CREATE SCHEMA [Customers_Schema] AUTHORIZATION [Customers_Role] De
ny View
> Definition to [Customers_Role]
> exec sp_adduser 'phenson', 'phenson', [Customers_Role]
> GRANT SELECT ON [dbo].[PT_VIEW] TO [Customers_Role]
>
> When I log in as phenson I do not see PT_View but I can query on it. I ne
ed
> to be able to see it.
> "SpankyATL" wrote:
>|||SpankyATL (SpankyATL@.discussions.microsoft.com) writes:
> Here's the commands that I'm executing in order:
> CREATE ROLE [Customers_ROLE] Authorization dbo
> CREATE SCHEMA [Customers_Schema] AUTHORIZATION [Customers_Role] De
ny View
> Definition to [Customers_Role]
> exec sp_adduser 'phenson', 'phenson', [Customers_Role]
> GRANT SELECT ON [dbo].[PT_VIEW] TO [Customers_Role]
>
> When I log in as phenson I do not see PT_View but I can query on it. I
> need to be able to see it.
Why then did you do DENY VIEW DEFINITION to a role that you made phenson a
member of?
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||I was working from a script that was given to me. The person who developed
it mistakenly thought deny view would only deny the user from viewing the
source code.
"Erland Sommarskog" wrote:

> SpankyATL (SpankyATL@.discussions.microsoft.com) writes:
> Why then did you do DENY VIEW DEFINITION to a role that you made phenson a
> member of?
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx
>

CAN USER EDIT DATA in the report?

Hi,
I have a report which shows all the orders in the systam . I want to be able
to view the order details for an order when an order number is clicked and be
able to edit some information so thagt it goes back to the databse. Is it
possible to edit data with REpotrting svcs?
If not, then is there a way, i can show all the orders in the databse, and
have a link in the report which takes the user to a web page where the user
can edit the order and then after editing the order, he again can view the
orginal (all orders ) in the system from the report and then click a link
which takes the user to the order details of that order so that the order can
be edited?
--
pmudNo, it is not possible to edit data in report in place.
Yes, it is possible to make a URL link to the edit page for every order.
You just need to setup an action for the textbox with order id that will be
an http link with order id parameter. Action is visible in properties for
the textbox.
"pmud" <pmud@.discussions.microsoft.com> wrote in message
news:7CC6E584-B705-45A9-B83A-9821109B592A@.microsoft.com...
> Hi,
> I have a report which shows all the orders in the systam . I want to be
able
> to view the order details for an order when an order number is clicked and
be
> able to edit some information so thagt it goes back to the databse. Is it
> possible to edit data with REpotrting svcs?
> If not, then is there a way, i can show all the orders in the databse,
and
> have a link in the report which takes the user to a web page where the
user
> can edit the order and then after editing the order, he again can view the
> orginal (all orders ) in the system from the report and then click a link
> which takes the user to the order details of that order so that the order
can
> be edited?
> --
> pmudsql

Can use some help with a select query

Hi,

I have this tables (view attachment) wich i want to query with a selct statement I'll tried al sort of things but it didn't happend!

I have a machine which has one cabinet in this cabinet there could be 2 screens , I want the details of both screens of a certain machine in a single line
Hope somesone understand what i want!

Cheers WimmoAs a matter of fact, no I don't understand.
It sounds like you are describing a crosstab query, but your schema allows only one screen per cabinet.
It would be best if you posted the query you have tried, and let us know how the results differed from what you wanted.|||Untested:
select *
from tblMachine m
,tblCabinet c
,tblScreens s1
left join tblScreens s2 on c.Screen2=s2.Part_Number
where m.Cabinet=c.id
and c.Screen1=s1.Part_Number|||Untested:
select *
from tblMachine m
,tblCabinet c
,tblScreens s1
left join tblScreens s2 on c.Screen2=s2.Part_Number
where m.Cabinet=c.id
and c.Screen1=s1.Part_Numberi would be extremely leery of mixing "comma list" syntax with JOIN syntax

in mysql 5, for instance, JOINs take precedence (similar to the way ANDs take precedence over ORs) and so the following will produce an error --tblScreens s1 left join tblScreens s2
on c.Screen2=s2.Part_Numbercan you see why?|||Yes the left join should be to tblCabinet i.e.
select ...
from tblMachine m
, tblScreens s1
, tblCabinet c
left join tblScreens s2 on c.Screen2=s2.Part_Number
where m.Cabinet=c.id
and c.Screen1=s1.Part_Number

And as you say this is just as bad as mixing ANDs and ORs without brackets
Thanks for highlighting it
So here it is without mixing syntax
select ...
from tblMachine m
,tblCabinet c
,tblScreens s1
,tblScreens s2
where m.Cabinet=c.id
and c.Screen1=s1.Part_Number
and c.Screen2*=s2.Part_Number

select ...
from tblMachine m
join tblCabinet c on m.Cabinet=c.id
join tblScreens s1 on c.Screen1=s1.Part_Number
left join tblScreens s2 on c.Screen2=s2.Part_Number|||Hi All, thanx for your reply's.
I tried the query's but none did actually worked, they generated no errors but it returned zero records where ther should be one.

@.Blindman, I tried this query for getting the info of 1 screen which is already hard to get but there could be 2 or none in a cabinet

SELECT tblCabinet.Screen1, tblCabinet.Screen2, tblScreenTypes.ScreenType, tblBrands.BrandName, tblCommTypes.CommType, tblAdaptor.Adaptor
FROM tblMachine INNER JOIN
tblCabinet ON tblMachine.Cabinet = tblCabinet.ID INNER JOIN
tblScreens ON tblCabinet.Screen1 = tblScreens.Part_Number INNER JOIN
tblScreenTypes ON tblScreens.ScreenType = tblScreenTypes.ID INNER JOIN
tblBrands ON tblScreens.Brand = tblBrands.ID INNER JOIN
tblAdaptor ON tblScreens.Adaptor = tblAdaptor.ID INNER JOIN
tblCommTypes ON tblScreens.CommType = tblCommTypes.ID
where tblMachine.Part_NUmber = 'Value'

I'll tried several changes in the joins but none returned an error but none returned values.|||If your query unexpectedly returned zero rows, then run this and see how many rows it returns:SELECT count(*)
FROM tblMachine
-- INNER JOIN tblCabinet ON tblMachine.Cabinet = tblCabinet.ID
-- INNER JOIN tblScreens ON tblCabinet.Screen1 = tblScreens.Part_Number
-- INNER JOIN tblScreenTypes ON tblScreens.ScreenType = tblScreenTypes.ID
-- INNER JOIN tblBrands ON tblScreens.Brand = tblBrands.ID
-- INNER JOIN tblAdaptor ON tblScreens.Adaptor = tblAdaptor.ID
-- INNER JOIN tblCommTypes ON tblScreens.CommType = tblCommTypes.ID
where tblMachine.Part_NUmber = 'Value'
Then, uncomment one line at a time until your query again returns zero rows, and that will tell you where the problem join is.|||I'll did what you suggested and at this line

INNER JOIN tblScreens ON tblCabinet.Screen1 = tblScreens.Part_Number

it returns 0 but i don´t understand why, there are values. Could it have something todo with the relation?

Thanks to your proposed strategy i found the problem, seems that there was a relation to an old table on screen 1 so deleting that table did solve my problem.

Thanks for all your help and probably expensive time.

Wim

Can update in SQL 2000 but not express beta 2

I have come across a interesting problem when creating a datagrid view in Sql express beta 2.

I created a database shop and table customers using sql manager qeries

create database shop;

use shop
create table customers(customerID int);
use shop
insert into customers VALUES ('1');

Pathetically simple I know!!, I created the same table in SQL 2000 using enterprise manager.

When I create a new C# windows project in VS2005, create a new data source and use the express data base by dragging the datagrid straight from the data sources window, I run it and it fails to update 1 to 2
the code it failing at is


return this.Adapter.Update(dataTable);

in dataset1.designer.cs

However simply creating a new project and adding the SQL 2000 instance of the database works fine

I was just wondering if anybody else has come across this problem

Regards Ross

So I worked out the problem,

in SQL express manager when I was making the tables using sql statements I neglected to set a primary key, when I made the tables in sql 2000 Enterprise manager I added primary keys out of habbit, so basically make sure primary keys are set in the tables.

can u help with my select ?

Hello All,

I have a simple table with 2 columns.

datetime int
27.05.04 1
29.05.04 2
31.05.04 5

and i need to get a view that looks like this below :

27.05.04 1 1
29.05.04 2 3
31.05.04 5 8

The third column shows a sum of numbers that were display before present one
...
I was trying build stored proc however I'm not so familiar with SQL so I
failed.. :-(

can anybody help ?

thx in advance
Krzysiek"Krzysiek" <krzysiek79@.hotmail.com> wrote in message
news:c9fq48$25ka$1@.news2.ipartners.pl...
> Hello All,
> I have a simple table with 2 columns.
> datetime int
> 27.05.04 1
> 29.05.04 2
> 31.05.04 5
> and i need to get a view that looks like this below :
> 27.05.04 1 1
> 29.05.04 2 3
> 31.05.04 5 8
> The third column shows a sum of numbers that were display before present
one
> ..
> I was trying build stored proc however I'm not so familiar with SQL so I
> failed.. :-(
> can anybody help ?
> thx in advance
> Krzysiek

It looks like you got an answer in another group - please do not post to
multiple groups independently.

Simon

Sunday, March 11, 2012

Can subscriber be a partitioned view?

Can a subscriber be a partitioned view?
No it can't be a partitioned view.
But you can replicate to a table which can be part of a part of a
distributed partitioned view.
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
"Richard" <no@.no.com> wrote in message
news:eZJrJPozHHA.5484@.TK2MSFTNGP03.phx.gbl...
> Can a subscriber be a partitioned view?
>

Friday, February 24, 2012

Can somebody tell me what is wrong with this?

I am trying to created a view and have a need for conditional logic:

Here is what I presently have (not working):
-----------------------
IF (ISDATE(COMPLETIONDATE) = 1)
BEGIN
CASE
WHEN DATEDIFF(d, COMPLETIONDATE, RESET.RESET_UNIT.MCD) > (SELECT GREEN FROM RESET.THRESHOLDS WHERE TYPE = 'SCHEDULE') THEN 'GREEN'
WHEN DATEDIFF(d, COMPLETIONDATE, RESET.RESET_UNIT.MCD) < (SELECT GREEN FROM RESET.THRESHOLDS WHERE TYPE = 'SCHEDULE') AND DATEDIFF(d, COMPLETIONDATE, RESET.RESET_UNIT.MCD) > 0 THEN 'YELLOW'
WHEN DATEDIFF(d, COMPLETIONDATE, RESET.RESET_UNIT.MCD) < 0 THEN 'RED'
END AS THRESHOLDSTATUS
END
ELSE
IF (ISDATE(COMPLETIONDATE) = 0)
BEGIN
CASE
WHEN DATEDIFF(d, TARGETCOMPLETIONDATE, RESET.RESET_UNIT.MCD) > (SELECT GREEN FROM RESET.THRESHOLDS WHERE TYPE = 'SCHEDULE') THEN 'GREEN'
WHEN DATEDIFF(d, TARGETCOMPLETIONDATE, RESET.RESET_UNIT.MCD) < (SELECT GREEN FROM RESET.THRESHOLDS WHERE TYPE = 'SCHEDULE') AND DATEDIFF(d, TARGETCOMPLETIONDATE, RESET.RESET_UNIT.MCD) > 0 THEN 'YELLOW'
WHEN DATEDIFF(d, TARGETCOMPLETIONDATE, RESET.RESET_UNIT.MCD) < 0 THEN 'RED'
END AS THRESHOLDSTATUS
END
-----------------------

Can someone tell me what I am doing wrong?

Basically I am trying to test to see if "completiondate" is a date and if it is then perform a case operation using it, if it is not a date then I want to perform the case operation using "targetcompletiondate".

Thanks...select THRESHOLDSTATUS =
CASE
WHEN DATEDIFF(d, case when ISDATE(COMPLETIONDATE) = 1 then COMPLETIONDATE else TARGETCOMPLETIONDATE end, RESET.RESET_UNIT.MCD) > (SELECT GREEN FROM RESET.THRESHOLDS WHERE TYPE = 'SCHEDULE') THEN 'GREEN'
WHEN DATEDIFF(d, case when ISDATE(COMPLETIONDATE) = 1 then COMPLETIONDATE else TARGETCOMPLETIONDATE end, RESET.RESET_UNIT.MCD) < (SELECT GREEN FROM RESET.THRESHOLDS WHERE TYPE = 'SCHEDULE') AND DATEDIFF(d, case when ISDATE(COMPLETIONDATE) = 1 then COMPLETIONDATE else TARGETCOMPLETIONDATE end, RESET.RESET_UNIT.MCD) > 0 THEN 'YELLOW'
WHEN DATEDIFF(d, case when ISDATE(COMPLETIONDATE) = 1 then COMPLETIONDATE else TARGETCOMPLETIONDATE end, RESET.RESET_UNIT.MCD) < 0 THEN 'RED'
END
from ...|||First problem: You have a column called "CompletionDate" which may contain something that is NOT A DATE?!?! That's a design issue right there...

Second problem: You are putting this in a VIEW? Complex logic such as this is better off in a stored procedure. You didn't provide your entire CREATE VIEW statement, but depending upon what you are trying to do, your task may not be possible.

You may be able to use nested CASE statements:
CASE WHEN ISDATE(COMPLETIONDATE) = 1
CASE WHEN DATEDIFF(d, COMPLETIONDATE, RESET.RESET_UNIT.MCD) > (SELECT GREEN FROM RESET.THRESHOLDS WHERE TYPE = 'SCHEDULE') THEN 'GREEN'
WHEN DATEDIFF(d, COMPLETIONDATE, RESET.RESET_UNIT.MCD) < (SELECT GREEN FROM RESET.THRESHOLDS WHERE TYPE = 'SCHEDULE') AND DATEDIFF(d, COMPLETIONDATE, RESET.RESET_UNIT.MCD) > 0 THEN 'YELLOW'
WHEN DATEDIFF(d, COMPLETIONDATE, RESET.RESET_UNIT.MCD) < 0 THEN 'RED'
END
ELSE
CASE WHEN DATEDIFF(d, TARGETCOMPLETIONDATE, RESET.RESET_UNIT.MCD) > (SELECT GREEN FROM RESET.THRESHOLDS WHERE TYPE = 'SCHEDULE') THEN 'GREEN'
WHEN DATEDIFF(d, TARGETCOMPLETIONDATE, RESET.RESET_UNIT.MCD) < (SELECT GREEN FROM RESET.THRESHOLDS WHERE TYPE = 'SCHEDULE') AND DATEDIFF(d, TARGETCOMPLETIONDATE, RESET.RESET_UNIT.MCD) > 0 THEN 'YELLOW'
WHEN DATEDIFF(d, TARGETCOMPLETIONDATE, RESET.RESET_UNIT.MCD) < 0 THEN 'RED'
END
END AS THRESHOLDSTATUS

...or a single CASE statement with more complex criteria:
CASE
WHEN ISDATE(COMPLETIONDATE) = 1 AND (DATEDIFF(d, COMPLETIONDATE, RESET.RESET_UNIT.MCD) > (SELECT GREEN FROM RESET.THRESHOLDS WHERE TYPE = 'SCHEDULE')) THEN 'GREEN'
WHEN ISDATE(COMPLETIONDATE) = 1 AND (DATEDIFF(d, COMPLETIONDATE, RESET.RESET_UNIT.MCD) < (SELECT GREEN FROM RESET.THRESHOLDS WHERE TYPE = 'SCHEDULE')) AND (DATEDIFF(d, COMPLETIONDATE, RESET.RESET_UNIT.MCD) > 0) THEN 'YELLOW'
WHEN ISDATE(COMPLETIONDATE) = 1 AND (DATEDIFF(d, COMPLETIONDATE, RESET.RESET_UNIT.MCD) < 0 THEN 'RED'
WHEN ISDATE(COMPLETIONDATE) = 0 AND (DATEDIFF(d, TARGETCOMPLETIONDATE, RESET.RESET_UNIT.MCD) > (SELECT GREEN FROM RESET.THRESHOLDS WHERE TYPE = 'SCHEDULE')) THEN 'GREEN'
WHEN ISDATE(COMPLETIONDATE) = 0 AND (DATEDIFF(d, TARGETCOMPLETIONDATE, RESET.RESET_UNIT.MCD) < (SELECT GREEN FROM RESET.THRESHOLDS WHERE TYPE = 'SCHEDULE')) AND (DATEDIFF(d, TARGETCOMPLETIONDATE, RESET.RESET_UNIT.MCD) > 0) THEN 'YELLOW'
WHEN ISDATE(COMPLETIONDATE) = 0 AND (DATEDIFF(d, TARGETCOMPLETIONDATE, RESET.RESET_UNIT.MCD) < 0 THEN 'RED'
END AS THRESHOLDSTATUS|||I thought that that's what I gave the poster...?|||Yeah, you sniped me by 10 minutes. So you get kudos for being first, but I get points for verbosity!

Tuesday, February 14, 2012

Can OPTION (ROBUST PLAN) be used inside of a VIEW?

(SQL Server 2000, SP3)
Hello all!
I've got a VIEW whose use seems to require the OPTION (ROBUST PLAN) query hint.
(Otherwise it's very dependant on the "width" of my data -- and I'll get errors if it
exceeds 8094 bytes.)
Can this hint be incorporated into the VIEW itself? When I try that, it seems to fail,
but I'm wondering if I'm putting it in the right place?
However, if I do it outside the VIEW:
select * from MyView option (robust plan)
Then it works. But, I'd prefer not to have to change my code to incorporate the OPTION
(ROBUST PLAN) query hint everywhere that I reference this VIEW.
Any suggestions?
Thanks!
John PetersonI don't see anything that states you can't use this in a view but your issue
may be outside the view itself. When you select against a view that selects
from views the optimizer tries to look at them all as a whole to get the
best plan. The view by itself may not run into this issue. I would try to
cut down the columns first and see if that helps.
--
Andrew J. Kelly
SQL Server MVP
"John Peterson" <j0hnp@.comcast.net> wrote in message
news:ej$ah9IdDHA.2932@.tk2msftngp13.phx.gbl...
> (SQL Server 2000, SP3)
> Hello all!
> I've got a VIEW whose use seems to require the OPTION (ROBUST PLAN) query
hint.
> (Otherwise it's very dependant on the "width" of my data -- and I'll get
errors if it
> exceeds 8094 bytes.)
> Can this hint be incorporated into the VIEW itself? When I try that, it
seems to fail,
> but I'm wondering if I'm putting it in the right place?
> However, if I do it outside the VIEW:
> select * from MyView option (robust plan)
> Then it works. But, I'd prefer not to have to change my code to
incorporate the OPTION
> (ROBUST PLAN) query hint everywhere that I reference this VIEW.
> Any suggestions?
> Thanks!
> John Peterson
>|||Hello Andrew!
Thanks for your help -- yeah, if I try to create a VIEW like:
create view Test
as
select * from sysobjects option (robust plan)
go
It will fail to create the VIEW (citing a syntax error near "option"). It's almost like I
can only have that OPTION clause "outside" of the VIEW. But, I don't want to have to
change a lot of code to explicitly put the OPTION clause in place for those objects that
are calling the VIEW -- I'd like to be able to do that in *one* place if at all possible.
Additional thoughts?
John Peterson
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:uv9%23UBKdDHA.652@.tk2msftngp13.phx.gbl...
> I don't see anything that states you can't use this in a view but your issue
> may be outside the view itself. When you select against a view that selects
> from views the optimizer tries to look at them all as a whole to get the
> best plan. The view by itself may not run into this issue. I would try to
> cut down the columns first and see if that helps.
> --
> Andrew J. Kelly
> SQL Server MVP
>
> "John Peterson" <j0hnp@.comcast.net> wrote in message
> news:ej$ah9IdDHA.2932@.tk2msftngp13.phx.gbl...
> > (SQL Server 2000, SP3)
> >
> > Hello all!
> >
> > I've got a VIEW whose use seems to require the OPTION (ROBUST PLAN) query
> hint.
> > (Otherwise it's very dependant on the "width" of my data -- and I'll get
> errors if it
> > exceeds 8094 bytes.)
> >
> > Can this hint be incorporated into the VIEW itself? When I try that, it
> seems to fail,
> > but I'm wondering if I'm putting it in the right place?
> >
> > However, if I do it outside the VIEW:
> >
> > select * from MyView option (robust plan)
> >
> > Then it works. But, I'd prefer not to have to change my code to
> incorporate the OPTION
> > (ROBUST PLAN) query hint everywhere that I reference this VIEW.
> >
> > Any suggestions?
> >
> > Thanks!
> >
> > John Peterson
> >
> >
>|||Thanks, Olaf -- that's exactly what I tried. Unfortunately, that doesn't appear to work
either. The only way to get that OPTION clause seems to be in a stored procedure of the
"base" call. :-(
"Olaf Pietsch" <olaf_pietsch@.t-online.de> wrote in message
news:ewq$B7OdDHA.2296@.TK2MSFTNGP09.phx.gbl...
> "John Peterson" <j0hnp@.comcast.net> wrote
> > create view Test
> > as
> > select * from sysobjects option (robust plan)
> > go
> >
> > It will fail to create the VIEW (citing a syntax error near
> > "option"). It's almost like I can only have that OPTION clause
> > "outside" of the VIEW. But, I don't want to have to change a lot of
> > code to explicitly put the OPTION clause in place for those objects
> > that are calling the VIEW -- I'd like to be able to do that in *one*
> > place if at all possible.
> If you can use an UDF:
> CREATE FUNCTION test_function ()
> RETURNS @.table_var TABLE (n varchar(100), id int)
> AS
> BEGIN
> INSERT @.table_var SELECT [name], id from sysobjects option (robust plan)
> RETURN
> END
> GO
> CREATE VIEW test
> AS
> SELECT * FROM [dbo].[test_function]()
> GO
> --
> Olaf
>
>
>|||Hi John,
"John Peterson" <j0hnp@.comcast.net> wrote
news:OpQaFVPdDHA.2748@.tk2msftngp13.phx.gbl
> Thanks, Olaf -- that's exactly what I tried. Unfortunately, that
> doesn't appear to work either. The only way to get that OPTION
> clause seems to be in a stored procedure of the "base" call. :-(
I tested my suggestion and is running successful, I use SQL 2000 SP3.
>> If you can use an UDF:
>> CREATE FUNCTION test_function ()
>> RETURNS @.table_var TABLE (n varchar(100), id int)
>> AS
>> BEGIN
>> INSERT @.table_var SELECT [name], id from sysobjects option (robust
>> plan) RETURN
>> END
>> GO
>> CREATE VIEW test
>> AS
>> SELECT * FROM [dbo].[test_function]()
>> GO
Sorry, did you test the same version really?
The following raises an error:
CREATE FUNCTION dbo.test_fn ()
RETURNS TABLE
AS
RETURN (
SELECT [name], id from sysobjects option (robust plan)
)
Server: Msg 156, Level 15, State 1, Procedure test_fn, Line 8
Incorrect syntax near the keyword 'option'.
--
Olaf|||Oh...you know what I did:
create function Test()
returns table
as
return(select * from sysobjects option (robust plan))
go
And *that* didn't work. I had hoped that I wouldn't have to define the table structure
and just be an inline function (IsInlineFunction as opposed to IsTableFunction). But I
guess that doesn't quite work.
If all else fails, I'll probably try your suggested technique. It really bugs me that the
VIEW needs the OPTION hint -- I'm hopeful to refactor it so that it's not required.
Thanks for your help!
"Olaf Pietsch" <olaf_pietsch@.t-online.de> wrote in message
news:u8C7ZFSdDHA.728@.TK2MSFTNGP11.phx.gbl...
> Hi John,
> "John Peterson" <j0hnp@.comcast.net> wrote
> news:OpQaFVPdDHA.2748@.tk2msftngp13.phx.gbl
> > Thanks, Olaf -- that's exactly what I tried. Unfortunately, that
> > doesn't appear to work either. The only way to get that OPTION
> > clause seems to be in a stored procedure of the "base" call. :-(
> I tested my suggestion and is running successful, I use SQL 2000 SP3.
> >> If you can use an UDF:
> >>
> >> CREATE FUNCTION test_function ()
> >> RETURNS @.table_var TABLE (n varchar(100), id int)
> >> AS
> >> BEGIN
> >> INSERT @.table_var SELECT [name], id from sysobjects option (robust
> >> plan) RETURN
> >> END
> >> GO
> >>
> >> CREATE VIEW test
> >> AS
> >> SELECT * FROM [dbo].[test_function]()
> >> GO
> Sorry, did you test the same version really?
> The following raises an error:
> CREATE FUNCTION dbo.test_fn ()
> RETURNS TABLE
> AS
> RETURN (
> SELECT [name], id from sysobjects option (robust plan)
> )
> Server: Msg 156, Level 15, State 1, Procedure test_fn, Line 8
> Incorrect syntax near the keyword 'option'.
> --
> Olaf
>

Can only see system tables

Hello,

I have created a linked server XYZ that is linked to server ABC. I am tying to view the tables via XYZ but I'm unable to do so. I can only see the system tables. When I run a select statement, I get the correct results. That means I have the access to the tables, yet why am I not able to see the tables.

Please assist

That highly depends on the type of linked server you are accessing. Which server are you accessing ?

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

Can Not View Reports (Please Help)

I am running RS on a W2K3 server. I have a report setup with a datasource to
use sql security. When I try to run the report from the server or from a
client I get a login failed for user "userid"
I am not sure what to check and have been toying with this for 3 days now. I
would appreciate any help!
Thank You.Andy,
I have nearly the exaxt same problem.
SQL Server 2000 SP3
SQL Reporting Services SP1 on the server and Report Designer client
W2K3 Server OS.
In Report Manager, I created a new role called View Reports Only which has
View Reports and View Folders permissions. I have assigned authenticated
users to have the View Reports Only role at the Home folder, which propagates
down through all folders and reports. Yet, the users get prompted with a
login / password dialogue when they try to view a report via a url link from
our intranet web page.
So far, the only way a user can run one of the reports is to be a member of
the Local Administrators group on the W2K3 server.
I have not loaded W2K3 Server SP1 yet. I wonder if any fixes for this
situation would be included with it. My company does not want to install
W2K3 Server SP1 on any of our live servers until we have time to do some
testing for any ill side affects.
I also have not loaded Reporting Services SP2 yet until I see fewer negative
posts on here about ill side affects. Unless it gurantees a fix for this
security issue.
Hopefully, someone on here can shed some light on this W2K3 security problem.
I have the exact same setup running on another server without any problems.
The only main difference is the server that behaves correctly is running W2K
Server OS, not W2K3 Server.
--
Owen B
SQL Report Writer
"Andy Jones" wrote:
> I am running RS on a W2K3 server. I have a report setup with a datasource to
> use sql security. When I try to run the report from the server or from a
> client I get a login failed for user "userid"
> I am not sure what to check and have been toying with this for 3 days now. I
> would appreciate any help!
> Thank You.
>
>|||Bump
--
Owen B
SQL Report Writer
"Owen B" wrote:
> Andy,
> I have nearly the exaxt same problem.
> SQL Server 2000 SP3
> SQL Reporting Services SP1 on the server and Report Designer client
> W2K3 Server OS.
>
> In Report Manager, I created a new role called View Reports Only which has
> View Reports and View Folders permissions. I have assigned authenticated
> users to have the View Reports Only role at the Home folder, which propagates
> down through all folders and reports. Yet, the users get prompted with a
> login / password dialogue when they try to view a report via a url link from
> our intranet web page.
> So far, the only way a user can run one of the reports is to be a member of
> the Local Administrators group on the W2K3 server.
> I have not loaded W2K3 Server SP1 yet. I wonder if any fixes for this
> situation would be included with it. My company does not want to install
> W2K3 Server SP1 on any of our live servers until we have time to do some
> testing for any ill side affects.
> I also have not loaded Reporting Services SP2 yet until I see fewer negative
> posts on here about ill side affects. Unless it gurantees a fix for this
> security issue.
> Hopefully, someone on here can shed some light on this W2K3 security problem.
> I have the exact same setup running on another server without any problems.
> The only main difference is the server that behaves correctly is running W2K
> Server OS, not W2K3 Server.
> --
> Owen B
> SQL Report Writer
>
> "Andy Jones" wrote:
> > I am running RS on a W2K3 server. I have a report setup with a datasource to
> > use sql security. When I try to run the report from the server or from a
> > client I get a login failed for user "userid"
> >
> > I am not sure what to check and have been toying with this for 3 days now. I
> > would appreciate any help!
> >
> > Thank You.
> >
> >
> >

Can Not View Report Server Web Pages

I have installed the Business Intelligence Studio on my PC and had no
problems creating a report, but when I go to http:\\localhost\reportserver,
I just see a directory listing in the browser instead of the web interface.
Where should I look to troubleshoot?
TIA
Dean> Where should I look to troubleshoot?
No place -- you're prolly fine.
Try http://localhost/reports if you want the Report Manager interface...
>L<
"Dean" <deanl144@.hotmail.com.nospam> wrote in message
news:%23p6kzVcqHHA.1220@.TK2MSFTNGP04.phx.gbl...
>I have installed the Business Intelligence Studio on my PC and had no
>problems creating a report, but when I go to http:\\localhost\reportserver,
>I just see a directory listing in the browser instead of the web interface.
>Where should I look to troubleshoot?
> TIA
> Dean
>