Showing posts with label line. Show all posts
Showing posts with label line. Show all posts

Wednesday, March 21, 2012

Problem performing a join on a function in a SQL query

Hello,

Can someone explain why this code contains the following error:

Msg 4104, Level 16, State 1, Line 2

The multi-part identifier "TheTable.StartValue" could not be bound.

CREATE FUNCTION MyFunction(@.StartValue int)

RETURNS @.MyTable TABLE

(

NextValue int NOT NULL

)

AS

BEGIN

INSERT INTO @.MyTable(NextValue)

VALUES (@.StartValue + 1)

INSERT INTO @.MyTable(NextValue)

VALUES (@.StartValue + 2)

RETURN

END

GO

CREATE TABLE TheTable

(

StartValue int NOT NULL

)

GO

INSERT INTO TheTable(StartValue)

VALUES (10)

INSERT INTO TheTable(StartValue)

VALUES (20)

GO

SELECT *

FROM TheTable CROSS JOIN

MyFunction(TheTable.StartValue)

You can′t do that per row. The logic is quite simple that you presented here, what about doing

SELECT StartValue, StartValue+1,StartValue+2
From SomeTable

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de|||

In SQL Server 2000, this is not possible. However, in 2005, you can use the CROSS APPLY join operator:

SELECT *
FROM TheTable
CROSS APPLY MyFunction(TheTable.StartValue)

Interesting function. If you don't mind, could you share the purpose?

|||

Hi,

you cannot use Table's Column as a parameter to the function. Only variables or Static Literals can be passed as an argument to the function

|||

Thanks for your reply.

I wrote that function as an example of what I was trying to do. I have a vertical bar delimited column (eg. this|is|my|column). I used a CLR function to get all the values. I then run a aggregate of these values based on another field in another table. So the output should be something like this.

this: 2
is: 4
my: 0
column: 1

I can't do a straight aggregate because the "my" values above would be omitted.

|||

Thanks for your reply.

I wrote that function as an example of what I was trying to do. I have a vertical bar delimited column (eg. this|is|my|column). I used a CLR function to get all the values. I then run a aggregate of these values based on another field in another table. So the output should be something like this.

this: 2
is: 4
my: 0
column: 1

I can't do a straight aggregate because the "my" values above would be omitted.

Problem passing parameters to sub report

Hi,

I'm hoping this will be an easy one for you gurus:

I have a report with 2 groups and a detail line. I have put a sub report in the group1 footer. Now I can pass the main reports parameters down to the sub-report no problems. The problem I have is that I coded an "All" option into the reps parameter, so that I can report on (for example) all reps sales rather than just one.

Problem is that I need each groups rep ID passed down to the sub report. If I pass the All parameter, the report gives me all reps results in the group footer of each rep. I have tried passing the reportitems!txtrepid.value (the text field holding the repID value in the report) to the sub report, but that doesn't work.

Any ideas?

I also tried using fields!repid.value - I just get "sub report cannot be displayed". If I change it back to use a report parameter, it works - but does not give me what I need.

Any ideas anyone?

|||

Sussed it.

The sub report was looking for a string parameter 3 chars long. The field on the table that I was querying was 15 chars long - therefore it was being padded out with spaces - this made my sub report fail.

I used a LTRIM(RTRIM(S.SlPrsnId)) in my SQL, and low and behold it works!!

Problem opening SSMS Express

Hi,
I experience a problem after installing "SQL Server 2005 Books On Line"
(December 2005) on my notebook, which have also an installation of SQL
Server 2005 Express Edition. Management Studio Express Edition (November
CTP) don't start...
If I try to open it, nothing happens. Anyone can help me?
Thanks
David
David wrote:
> Hi,
> I experience a problem after installing "SQL Server 2005 Books On Line"
> (December 2005) on my notebook, which have also an installation of SQL
> Server 2005 Express Edition. Management Studio Express Edition (November
> CTP) don't start...
> If I try to open it, nothing happens. Anyone can help me?
> Thanks
I find the solution:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=57857
David

Monday, March 12, 2012

Problem moving Report Server catalog to different machine

Books On Line makes breaking out the report server databases on to a separate machine from the report server itself sound very easy. I have tried it and it is but I can't get the report server to connect to the databases once they are on the other machine.

Everything was done by the book(s). We use SSRS only for intranet use so all inside firewall. The SQL Server 2005 services on both machines (including the RS Windows service) all run as the same domain administrator account, this account was used to log in to RS Config Tool and it was told to use this account under Windows Authentication to connect to the database server. The two machines are in the same domain, even on the same switch. The only difference is the one with report server on is Windows 2000 Server SP4 and the one to which the rs databases are moving is Windows Server 2003 SP1. The account mentioned above has sysadmin rights on both SQL Servers, as well as having all the RSExecRole rights as specified in BOL. And it has rights to logon as a service in group policy on both machines. Its password hasn't been changed.

The RS Config Tool completed fine and reported no errors.

But when you try to connect to the report server you get the error:

"The report server cannot open a connection to the report server database. The logon failed. (rsReportServerDatabaseLogonFailed)" The log shows that a privilege required by the client is missing but doesn't specify what! I thought this was all taken care of when the RS Config Tool told it which account to connect with.

This is driving me daft. It should be so easy!! Does anyone have any idea what might be wrong? Nothing says I need to do anything with the encryption key when I am keeping the report server itself exactly as it was and just moving the catalog - or have I missed something here?

Grateful for any ideas.

IP Logged

Try using the Configuration Utility to generate a database script and apply that script manually in SSMS. In addition, the following posts may help (http://prologika.com/CS/blogs/blog/archive/2004/08/20/161.aspx and http://prologika.com/CS/blogs/blog/archive/2006/07/18/Swapping-the-RS-Catalog.aspx).|||

I have finally fixed this problem.

The "privilege required by the client" turned out to be "Act as part of operating system" for the ASPNET user (under which the RS web service runs) on its own native machine which is Windows 2000 Server.

Since it did not require this privilege when the report server catalog was also on this machine then I can only assume it became necessary either in principle when that catalog was moved, in which case you would think Books On Line would tell you, or because they had been moved to a Windows 2003 server machine and there then appeared some obscure (to me anyway!) conflict.

I don't suppose this would be much of a fix if either of the servers involved faced the internet but they are entirely internal so I am going with it.