Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 581203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:33:14+00:00 2026-05-13T14:33:14+00:00

Is it possible to create and use a user defined function in a report

  • 0

Is it possible to create and use a user defined function in a report query?

Something like this:

if OBJECT_ID('userFunc', 'TF') is not null drop function userFunc
go

create function userFunc(@id int)
returns @tbl table
([id] int)
begin
insert into @tbl (id) values(@id)
return
end
go

select * from userFunc(1)

if OBJECT_ID('userFunc', 'TF') is not null drop function userFunc

When i run this query in SQL Server 2008 Management Studio it returns me ‘id’:1, but when i put this query into Reporting Query designer – i get the next error:

TITLE: Microsoft Report Designer

An error occurred while the query
design method was being saved.
Incorrect syntax near ‘go’.

‘CREATE FUNCTION’ must be the first
statement in a query batch.

Incorrect syntax near ‘go’.

Incorrect syntax near ‘userFunc’.

Any suggestions? How to create and use udf in Reporting Services queries?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:33:14+00:00Added an answer on May 13, 2026 at 2:33 pm

    “GO” will only be recognised by SQL tools: not the DB engine nor SSRS parser

    This might if you really want to

    EXEC 'if OBJECT_ID(''userFunc'') is not null drop function userFunc'
    EXEC 'create function userFunc(@id int)
    returns @tbl table
    ([id] int)
    begin
    insert into @tbl (id) values(@id)
    return
    end'
    select * from userFunc(1)
    

    However, you’ll need ddl_admin or db_owner to run it.

    Have you considered a CTE or derived table? A table valued udf like this can be replaced by a CTE

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHP method chaining? I had a function for create user, like cruser
Is it possible to use the Type.<T> syntax with user defined classes? For example,
I created a User Defined Function with VB.NET and want to use that function
I would like to use create a rails route for a user's open id.
From the MSDN docs for create function : User-defined functions cannot be used to
In SQL Server 2005, I'm trying to use a User Defined Function in a
When creating a user defined function is it bad to just automatically use the
So I know that it's possible to create scripts for use on spreadsheets using
Is It possible to create HTML5 Web Socket by use of ASP.NET/Web Form?
Is it possible to use javascript to populate multidimensional arrays. I want to create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.