problem with [SqlException (0x80131904): Invalid object name 'dbo.TableName'.]

前端 未结 1 1471
北海茫月
北海茫月 2021-01-03 12:19

I was looking in google and stackoverflow and i did not find the answer, how can I connect to my database table through that connection string in VS 2010 ?

         


        
相关标签:
1条回答
  • 2021-01-03 13:01

    i found that answer and it helped !

    source: http://blogs.x2line.com/al/articles/155.aspx

    MSSQL: Change tables owner to dbo with sp_changeobjectowner

    Sometimes there is a need to change all tables in the database to be owned by dbo for maintenance or to fix up accidental errors. All tables owned by dbo schema is usually best practices in the database application development with MSSQL while we can meet different approaches in real life...

    The following small SQL code snippet goes through all user tables in the database and changes their owner to dbo. It uses sp_changeobjectowner system stored procedure:

    DECLARE tabcurs CURSOR
    FOR
    SELECT 'SOMEOWNER.' + [name]
      FROM sysobjects
     WHERE xtype = 'u'
    
    OPEN tabcurs
    DECLARE @tname NVARCHAR(517)
    FETCH NEXT FROM tabcurs INTO @tname
    
    WHILE @@fetch_status = 0
    BEGIN
    
    EXEC sp_changeobjectowner @tname, 'dbo'
    
    FETCH NEXT FROM tabcurs INTO @tname
    END
    CLOSE tabcurs
    DEALLOCATE tabcurs
    
    0 讨论(0)
提交回复
热议问题