Showing posts with label manager. Show all posts
Showing posts with label manager. Show all posts

Sunday, March 11, 2012

declare syntax in a UDF

Hi, I'm trying to create a function that returns a table, however I want
to use a local variable in there and enterprise manager ain't liking it!

The error I get is number 156 'incorrect syntax near the keyword
'declare'.. hopefully this is just a simple thing where I've put it in
the wrong place.

The code follows:

CREATE FUNCTION AFGroupedTotals (@.campaign nvarchar(30),@.datefrom
smalldatetime, @.dateto smalldatetime, @.prospect nvarchar(30), @.type
nvarchar(20))

RETURNS TABLE AS
RETURN

declare @.set nvarchar(150)

select "Total Pledged" as info, sum(total) as tot
FROM AFresponseTotals (@.campaign, @.datefrom, @.dateto,@.prospect)

Cheers for any help,
Chris"Not Me" <Noone.is.home@.here.com> wrote in message
news:ckoccr$olo$1@.ucsnew1.ncl.ac.uk...
> Hi, I'm trying to create a function that returns a table, however I want
> to use a local variable in there and enterprise manager ain't liking it!
> The error I get is number 156 'incorrect syntax near the keyword
> 'declare'.. hopefully this is just a simple thing where I've put it in the
> wrong place.
> The code follows:
> CREATE FUNCTION AFGroupedTotals (@.campaign nvarchar(30),@.datefrom
> smalldatetime, @.dateto smalldatetime, @.prospect nvarchar(30), @.type
> nvarchar(20))
> RETURNS TABLE AS
> RETURN
> declare @.set nvarchar(150)
> select "Total Pledged" as info, sum(total) as tot
> FROM AFresponseTotals (@.campaign, @.datefrom, @.dateto,@.prospect)
>
> Cheers for any help,
> Chris

You seem to be mixing inline and multi-statement syntax. If you just say
RETURN TABLE, then the rest of the function can only be a single SELECT
statement; if you want to use multiple statements in the function, then you
must define the structure of the table you're returning. See the examples in
Books Online under CREATE FUNCTION.

In your function, you haven't defined the structure of the returned table,
so the only thing you can have in the body of the function is a single
SELECT.

Simon|||Simon Hayes wrote:
> "Not Me" <Noone.is.home@.here.com> wrote in message
> news:ckoccr$olo$1@.ucsnew1.ncl.ac.uk...
>>The error I get is number 156 'incorrect syntax near the keyword
>>'declare'.. hopefully this is just a simple thing where I've put it in the
>>wrong place.
>>
>>The code follows:
>>
>>CREATE FUNCTION AFGroupedTotals (@.campaign nvarchar(30),@.datefrom
>>smalldatetime, @.dateto smalldatetime, @.prospect nvarchar(30), @.type
>>nvarchar(20))
>>RETURNS TABLE AS
>>RETURN
>>declare @.set nvarchar(150)
>>select "Total Pledged" as info, sum(total) as tot
>>FROM AFresponseTotals (@.campaign, @.datefrom, @.dateto,@.prospect)
> You seem to be mixing inline and multi-statement syntax. If you just say
> RETURN TABLE, then the rest of the function can only be a single SELECT
> statement; if you want to use multiple statements in the function, then you
> must define the structure of the table you're returning. See the examples in
> Books Online under CREATE FUNCTION.

Aha! sounds about right, just needed a little shunt in the right
direction.. gonna have nightmares about BOL :p

cheers,
Chris

Friday, February 24, 2012

Debugging Report Manager

Hi,
I have created a custom data processing extension that retrieves a Data
Table object from my DAL. It all works fine in the report designer, I can
preview the report and data is returned etc However when I deploy the report
and then try to access via the report manager web interface I get an error
has occurred during report processing... I can't for the life of me see what
is could be causing the error and I don't know how to debug this
Can anyone provide any useful tips/tricks?
ThanksMy bet is that dotnet security is tripping you up. When in development you
are the admin of the box and have all the rights you need to do anything.
The context of your assembly in production is different and you need to
setup the rights for the assembly. That is my guess anyway.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Neil" <Neil@.discussions.microsoft.com> wrote in message
news:B8854717-92A7-4ED1-8FDC-0D8462A594AB@.microsoft.com...
> Hi,
> I have created a custom data processing extension that retrieves a Data
> Table object from my DAL. It all works fine in the report designer, I can
> preview the report and data is returned etc However when I deploy the
> report
> and then try to access via the report manager web interface I get an error
> has occurred during report processing... I can't for the life of me see
> what
> is could be causing the error and I don't know how to debug this
> Can anyone provide any useful tips/tricks?
> Thanks
>

Friday, February 17, 2012

debug via Enterprise Manager

Hi
I wonder if there is a trick I can use to debug what was changed in my
database (mssql2000).
The idea maybe sound stupid but my boss have got old console application
which is doing some changes in database (only in data in tables rather:). I
have no code for that application and we are wondering where this appl.
writes - what changes and so on.
Any idea?
DarekHi
You may want to use SQL Profiler to see what statements the application is
sending to the database server.
John
"Dariusz Tomon" <d.tomon@.mazars.pl> wrote in message
news:eIJBW$aKGHA.216@.TK2MSFTNGP15.phx.gbl...
> Hi
> I wonder if there is a trick I can use to debug what was changed in my
> database (mssql2000).
> The idea maybe sound stupid but my boss have got old console application
> which is doing some changes in database (only in data in tables rather:).
> I have no code for that application and we are wondering where this appl.
> writes - what changes and so on.
> Any idea?
> Darek
>

debug via Enterprise Manager

Hi
I wonder if there is a trick I can use to debug what was changed in my
database (mssql2000).
The idea maybe sound stupid but my boss have got old console application
which is doing some changes in database (only in data in tables rather. I
have no code for that application and we are wondering where this appl.
writes - what changes and so on.
Any idea?
DarekHi
You may want to use SQL Profiler to see what statements the application is
sending to the database server.
John
"Dariusz Tomon" <d.tomon@.mazars.pl> wrote in message
news:eIJBW$aKGHA.216@.TK2MSFTNGP15.phx.gbl...
> Hi
> I wonder if there is a trick I can use to debug what was changed in my
> database (mssql2000).
> The idea maybe sound stupid but my boss have got old console application
> which is doing some changes in database (only in data in tables rather.
> I have no code for that application and we are wondering where this appl.
> writes - what changes and so on.
> Any idea?
> Darek
>

debug via Enterprise Manager

Hi
I wonder if there is a trick I can use to debug what was changed in my
database (mssql2000).
The idea maybe sound stupid but my boss have got old console application
which is doing some changes in database (only in data in tables rather. I
have no code for that application and we are wondering where this appl.
writes - what changes and so on.
Any idea?
Darek
Hi
You may want to use SQL Profiler to see what statements the application is
sending to the database server.
John
"Dariusz Tomon" <d.tomon@.mazars.pl> wrote in message
news:eIJBW$aKGHA.216@.TK2MSFTNGP15.phx.gbl...
> Hi
> I wonder if there is a trick I can use to debug what was changed in my
> database (mssql2000).
> The idea maybe sound stupid but my boss have got old console application
> which is doing some changes in database (only in data in tables rather.
> I have no code for that application and we are wondering where this appl.
> writes - what changes and so on.
> Any idea?
> Darek
>