Interlude: Troubleshooting for Failed to Declare Table-type Variables

    xiaoxiao2021-12-14  41

    When you declare like: 

     

     select * into @testitout from students 

     

    or 

     

    DECLARE @TESTITOUT TABLE 

     select * into @testitout from students 

     

    or 

     

     insert lastfirst into @testitout from students 

     

    You may get a message like 

     

    Msg 102, Level 15, State 1, Line 321 

    Incorrect syntax near 'TABLE'. 

     

     

       

    SQL SERVER don’t allow us to declare  Table-type Variables by those word, so we have to re-design when we use it. 

     

    But for temporary table, you can use script all the same as create a real table, like: 

     

     select * into #testitout from students 

     

     

    --check it-- 

     select * from #testitout 

       

     

    转载请注明原文地址: https://ju.6miu.com/read-963153.html

    最新回复(0)