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

  • Home
  • SEARCH
  • 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 8594393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:11:25+00:00 2026-06-12T00:11:25+00:00

Actually I have created a User defined table type in sql server 2008. Structure

  • 0

Actually I have created a User defined table type in sql server 2008. Structure is given below.

I am passing it as parameter in function and that function also return that type of table type. I am facing the problem, while I declare a variable of that type in function, inserting some data in it and return that parameter.

Table type structure is:

Create Type OfferWithSubscription  as  Table                                        
   (                                        
     OfferID int, 
     OfferUserID  int,                                    
     OfferImage  varchar(200),                          
     OfferExactPrice Decimal(18,2),                                
     OfferContent varchar(max),
     OfferTitle varchar(100),                                    
     StartDate datetime,                                    
     EndDate datetime,                                    
     StartTime datetime,                                    
     StopTime datetime,                            
     ShowToUser bit,    
     SubID  int,                    
     SubLevel varchar(100)
   )

And the function, what I am trying to create is:

CREATE FUNCTION FN_ShowOffer
(   
    @Gold int,
    @Silver int,
    @Bronze int,
    @table dbo.OfferWithSubscription Readonly )
RETURNS dbo.OfferWithSubscription 
AS
BEGIN

DECLARE @ReturnTable AS dbo.OfferWithSubscription;
Declare @Case as varchar(20)
         if(@Gold=0 and @Silver=1 and @Bronze=0 )
            begin
            set @Case='1S'
            end
           if(@Case='1S')
           Begin
                   insert into @ReturnTable                                    
                   select OfferID, OfferUserID, OfferImage, 
                     OfferExactPrice, OfferContent,
                     OfferTitle, StartDate, EndDate, 
                     StartTime, StopTime, ShowToUser,
                     SubID, SubLevel
                   from @table
                   where SubID=4 
           End

RETURN (

@ReturnTable
)
END
  • 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-06-12T00:11:26+00:00Added an answer on June 12, 2026 at 12:11 am

    You’ll just have to expand the type like below.
    FYI – Can T-SQL function return user-defined table type?

    CREATE FUNCTION FN_ShowOffer
    (   
        @Gold int,
        @Silver int,
        @Bronze int,
        @table dbo.OfferWithSubscription Readonly )
    RETURNS @ReturnTable Table                                        
       (                                        
         OfferID int, 
         OfferUserID  int,                                    
         OfferImage  varchar(200),                          
         OfferExactPrice Decimal(18,2),                                
         OfferContent varchar(max),
         OfferTitle varchar(100),                                    
         StartDate datetime,                                    
         EndDate datetime,                                    
         StartTime datetime,                                    
         StopTime datetime,                            
         ShowToUser bit,    
         SubID  int,                    
         SubLevel varchar(100)
       )
    AS
    BEGIN
    Declare @Case as varchar(20)
             if(@Gold=0 and @Silver=1 and @Bronze=0 )
                begin
                set @Case='1S'
                end
               if(@Case='1S')
               Begin
               insert into @ReturnTable                                    
                 select OfferID,OfferUserID,OfferImage,OfferExactPrice,OfferContent,OfferTitle,
                 StartDate,EndDate,StartTime,StopTime,ShowToUser,SubID,SubLevel from @table where SubID=4 
               End
    
    RETURN
    END
    

    And to further clarify, that’s fully compatible and assignable to a variable of that table type, e.g. SQL Fiddle

    declare @t OfferWithSubscription
    insert @t
    select * from fn_showoffer(1,2,3,@t)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tree structure in an sql table like so: CREATE TABLE containers
I have scenario to use the Temporary user defined type variable in transaction, but
I want to customize the parameter in createuser() method Membership Provider, Actually, i have
Actually I have a domain - domainone.com I have created a subdomain cname of
I have created an Activity that will behave like a popup menu is actually
I have created a sub-domain forum.new4u.com for the site new4u.com . Actually the forum
Actually, in my app, I have created a graph using achartEngine . In these
I have a View (created using Backbone.View.extend) and a JSON object, I actually get
I have a route defined with several hardcoded (non-parameter) segments: routes.MapRoute(null, suggestion/list/by/{tag}, new {
I am creating a new table in Microsoft SQL server 2000 by writing the

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.