Why does my typed dataset not like temporary tables?

前端 未结 2 889
忘掉有多难
忘掉有多难 2021-01-04 14:11

I am attempting add a tableadapter to a stored procedure in my SQL Server 2005 Express. The stored procedure, however, uses a temporary table called #temp. When creating the

相关标签:
2条回答
  • 2021-01-04 14:18

    Bizarre. According to this you add

    IF 1=0 BEGIN
        SET FMTONLY OFF
    END
    

    to the SP right after the AS part of the SP and it works. Visual Studio now has no problem with it. I have no idea why this works like this, or why it would work, but it does.

    0 讨论(0)
  • 2021-01-04 14:38

    This may be an old thread and the answer is found, but when someone gets into your stored procedure after and see this code, he really does not understand. There is another way to do this properly and it is to simply declare the table as a variable like this :

    DECLARE @temp TABLE  
    (
        SomeText1 nvarchar(255),
        SomeText2 nvarchar(255)
    )
    

    Also, don't forget to remove the DROP TABLE at the end.

    PS : If you really need to use the temporary table because you need to create it, then you have to write the code given in the previous answer. Hope this helps.

    0 讨论(0)
提交回复
热议问题