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 538097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:59:45+00:00 2026-05-13T09:59:45+00:00

I am using SQL Server 2000 and feeling stuck about how to do this:

  • 0

I am using SQL Server 2000 and feeling stuck about how to do this:

I have a stored procedure that returns a single resultset which is bound to a gridview in a .Net web app.

Now I’d like to have a “table” so I can use it in an existing VB6 application like this:

SELECT * FROM myTable 

…where the schema of “myTable” is reflects the columns in the result set returned from this sproc.

Here is a script that works:

CREATE TABLE #ResultSet (
    StateFIPS           CHAR(2)
    ,CountyFIPS         CHAR(3)
,StateName          VARCHAR(30)
,CountyName         VARCHAR(40)
,MostRecentData_P       VARCHAR(20)
,PData              VARCHAR(3)
,AvgNbrMtgPerMonthInLastYear_P  INT
,MostRecentData_R       VARCHAR(20)
,RData              VARCHAR(3)
,AvgNbrMtgPerMonthInLastYear_R  INT
,MostRecentData_FHA     VARCHAR(20)
,MostRecentData_VA      VARCHAR(20)
)
INSERT INTO #ResultSet
EXECUTE dbo.FetchCoverageByState_V2 
SELECT * FROM #ResultSet

I tried to put this into a view but I get slapped with errors:

"Views or functions are not allowed on temporary tables"

I also tried a function like this:

create function dbo.udfCoverages() 

returns @ResultSet table (
    StateFIPS   CHAR(2)
    ,CountyFIPS CHAR(3)
,StateName  VARCHAR(30)
,CountyName VARCHAR(40)
,PData      VARCHAR(3)
,RData      VARCHAR(3)  
) as
INSERT @ResultSet (
    StateFIPS           CHAR(2)
    ,CountyFIPS         CHAR(3)
,StateName          VARCHAR(30)
,CountyName         VARCHAR(40)
,MostRecentData_P       VARCHAR(20)
,PData              VARCHAR(3)
,AvgNbrMtgPerMonthInLastYear_P  INT
,MostRecentData_R       VARCHAR(20)
,RData              VARCHAR(3)
,AvgNbrMtgPerMonthInLastYear_R  INT
,MostRecentData_FHA     VARCHAR(20)
,MostRecentData_VA      VARCHAR(20)
)
EXECUTE dbo.FetchCoverageByState_V2  
return

In the UDF attempt, I am getting syntax errors near the INSERT and I am wondering if SQL Server 2000 supports this.

What would you recommend?

EDIT-UPDATE (per first suggestion from Ray below):

create function dbo.udfCoverages() 
returns @ResultSet table (
    StateFIPS   CHAR(2)
    ,CountyFIPS CHAR(3)
,StateName  VARCHAR(30)
,CountyName VARCHAR(40)
,PData      VARCHAR(3)
,RData      VARCHAR(3)  
) as
BEGIN   
INSERT @ResultSet 
(
         StateFIPS          CHAR(2)
        ,CountyFIPS         CHAR(3)
    ,StateName          VARCHAR(30)
    ,CountyName         VARCHAR(40)
    ,MostRecentData_P       VARCHAR(20)
    ,PData              VARCHAR(3)
    ,AvgNbrMtgPerMonthInLastYear_P  INT
    ,MostRecentData_R       VARCHAR(20)
    ,RData              VARCHAR(3)
    ,AvgNbrMtgPerMonthInLastYear_R  INT
    ,MostRecentData_FHA     VARCHAR(20)
    ,MostRecentData_VA      VARCHAR(20)
)
    EXECUTE dbo.FetchCoverageByState_V2 
    return
END

Here I get: Line 19: Incorrect syntax near ‘CHAR’. NOTE: Line 19 is 2 lines after the INSERT above.

  • 1 1 Answer
  • 1 View
  • 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-13T09:59:45+00:00Added an answer on May 13, 2026 at 9:59 am

    Try using OPENROWSET, as in this question. I thought I had blogged about it some time, but perhaps not.

    Insert results of a stored procedure into a temporary table

    Remember to upvote Aaron’s answer.

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

Sidebar

Ask A Question

Stats

  • Questions 297k
  • Answers 297k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer accept_nested_attributes_for add the possibility to ActiveRecord to be able to… May 13, 2026 at 7:13 pm
  • Editorial Team
    Editorial Team added an answer When you create the vector, it allocates room for the… May 13, 2026 at 7:13 pm
  • Editorial Team
    Editorial Team added an answer Odd. I have used Text from codebehind to change the… May 13, 2026 at 7:13 pm

Related Questions

I'd like to trim these purchase order file names (a few examples below) so
I am using SQL Server 2000 and I have two databases that both replicate
I am using SQL Server 2000 and ASP.Net with c# for making a search
I am using SQL Server 2000 and want to write a simple query to
Guys, I am using SQL Server 2000 and executing the sp_columns stored procedure to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.