Showing posts with label below. Show all posts
Showing posts with label below. Show all posts

Friday, March 30, 2012

Pevious SQL statement for Reporting Services:

I need to write a SQL statement or IIF statement to get results that I need in Reporting Services. Below is what I need and I am unsure how to create the statement for my results.

I have a lot number which is associated with a PB Number and an Expected Start and Expected End Date that is running in production. The lot number is a parameter that the end user will key in the report. I need the report to display the previous lot number which ran on the same PB number. I think that I would need to use the Expected State Date and the Expected End date for that lot's running time in order to get the previous lot number. How would I write the SQL statement? ANY SUGGESTIONS?

Thanks, Ronda

So how do you define "previous lot number". Is it a lot number that has an earlier start date?

If that is the case I would try something like this

select top 1 LotNumber from table_name t1 where LotNumber != @.LotNum AND PbNumber in (select PbNumber from table_name t2 where LotNumber = @.LotNum) order by StartDate descending

I'm not sure about descending on the end. It might have to be ascending. I forgot how Dates are ordered.

sql

Saturday, February 25, 2012

Permission on view. Is there way to avoid granting persmission on the underlying table?

I want to grant access on the below view for an end user so that he connect to our SQL server and retrieve data. The view looks like the below

CREATE VIEW DB1.[dbo].[View1]
AS

-- For brevity, I made it as simple statement.
SELECT *

From DB2.dbo.table2

GO

For the above view, it looks like I have to grant select and connect permission for the DB1. [dbo].[View1] as well as DB2.dbo.table2.

1. Is my understanding correct?

2. I want the user to access only DB1. [dbo].[View1] and not the underlying tables. Is there a way to grant access only on the view and execute the statement on a different security context so that the user can’t access DB2.dbo.table2 directly?

3. When the user uses SQL Server Management Studio to connect to SQL server, he is able to connect and select DB2.dbo.table2 directly. Is there any way to restrict user from viewing and executing select statement on DB2 database from SQL Server Management Studio

Thanks in advance for your help

With regards

Ganesh

Because you are crossing databases, regular ownership chaining doesn’t apply. While it is possible to use cross-database ownership chaining (CDOC) for this scenario, I strongly discourage using it as enabling CDOC also enables some escalation of privileges opportunities.

I wrote an article in my blog that describes how to use digital signatures as an alternative, and it probably will be useful in your scenario:http://blogs.msdn.com/raulga/archive/2006/10/30/using-a-digital-signature-as-a-secondary-identity-to-replace-cross-database-ownership-chaining.aspx

NOTE: It is not possible to sign views directly, but it is possible to sign SP and multi-statement user-defined functions.

Also notice that using digital signatures it is possible to grant access to the target DB (DB2) via the signature without granting explicit CONNEC permission to the database on any other principal.

For the last part of your question; it is not possible to restrict actions based on the application, we have a separate discussion on this topic in the following link: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=790497&SiteID=1

I hope this information helps, let us know if you have any additional questions .

Thanks a lot,

-Raul Garcia

SDE/T

SQL Server Engine

|||Thanks a lot for your help. Does the digital signature concept applicable to view also?|||

No, unfortunately views cannot be signed. An alternative is to create a multistatement table-valued function (See BOL for details: http://msdn2.microsoft.com/en-us/library/ms186755.aspx) instead of a view, and you can insert into the return value of the view the same content the view would return.

I hope this helps,

-Raul Garcia

SDE/T

SQL Server Engine

Monday, February 20, 2012

Permission Denied Javascript errors

I have a report I've been running for several months using a URL like the one
below:
http://server/ReportServer?/folder/report&rs:Command=Render
I updated the report today and now I get 2 "Permission Denied" javascript
errors when the page loads. One is in function OnLoadToolbar calling
SetShowHideParameters and the other is in function LoadToolbarFrame on an if
statement (if (frames["oTbDMRepFram"0.location... The report works fine when
I go to the report manager in my browser and works fine in VS.NET. Any help
is appreciated.I found a workaround. I had unchecked "Show Friendly HTTP Errors" in my
browser. When I re-activated it, the report runs fine.
"jweesies" wrote:
> I have a report I've been running for several months using a URL like the one
> below:
> http://server/ReportServer?/folder/report&rs:Command=Render
> I updated the report today and now I get 2 "Permission Denied" javascript
> errors when the page loads. One is in function OnLoadToolbar calling
> SetShowHideParameters and the other is in function LoadToolbarFrame on an if
> statement (if (frames["oTbDMRepFram"0.location... The report works fine when
> I go to the report manager in my browser and works fine in VS.NET. Any help
> is appreciated.
>