SQL Server Error 4145

  • Hi,

    I have a stored procedure with the code below that is behaving strangely.

    I am working on a web application with C # Net and SQL Server 2008 R2.

    When I run the procedure within the IDE in Visual Studio, I get the message "The SQL syntax has been verified against datasource."

    I run in the Visual Studio 2010 IDE and the result is displayed without errors.

    The first time I run the web page that consumes the stored procedure, sometimes the result is displayed, also without error.

    The second time on, I always get the message SQL Server Error 4145.

    Can anyone help me?

    SELECT *

    FROM (

    SELECT ROW_NUMBER() OVER (ORDER BY Livros.LivroTitulo ASC) AS row,

    Livros.LivroId,

    Livros.LivroLojistaId,

    Livros.LivroStatusId,

    Livros.LivroMarcaId,

    Livros.LivroAutorId,

    Livros.LivroTitulo,

    Livros.LivroSubtitulo,

    Livros.LivroISBN13,

    Livros.LivroEAN13,

    Livros.LivroIdiomaId,

    Livros.LivroEstadoId,

    Livros.LivroAcabamentoId,

    Livros.LivroNumeroEdicao,

    Livros.LivroAnoPublicacao,

    Livros.LivroNumeroPaginas,

    Livros.LivroPrecoCusto,

    Livros.LivroPrecoCapa,

    Livros.LivroAliquotaIPI,

    Livros.LivroAliquotaICMS,

    Livros.LivroPeso,

    Livros.LivroAltura,

    Livros.LivroLargura,

    Livros.LivroImagemCapa,

    Livros.LivroResenha,

    Livros.LivroCriadoPorUsuarioId,

    Livros.LivroDataCadastro,

    Marcas.MarcaNome AS Editora,

    LivrosAutores.LivroAutorLivroId,

    Autores.AutorId,

    Autores.AutorNome AS Autor

    FROM Livros

    INNER JOIN Marcas ON Marcas.MarcaId = Livros.LivroMarcaId

    INNER JOIN LivrosAutores ON LivrosAutores.LivroAutorLivroId = Livros.LivroId AND LivrosAutores.LivroAutorAutorId = Livros.LivroAutorId

    INNER JOIN Autores ON Autores.AutorId = LivrosAutores.LivroAutorAutorId

    WHERE

    Livros.LivroTitulo LIKE 'só%') AS Tabela

  • Error 4145 is a syntax error.

    If you're getting syntax errors, the code you're running is different from the code you expect.

    Write it to a log file and see what's wrong with it.

    -- Gianluca Sartori

  • Thanks for answer. I will try, but how can i write a log inside procedure?

  • I think it's the procedure call that generates the error, not the procedure per se, unless you have dynamic code in your procedure.

    -- Gianluca Sartori

  • What is the text part of the error that follows the error code?

    Far away is close at hand in the images of elsewhere.
    Anon.

  • I'm using SQL Server 2008 R2 with Visual Studio 2010 When I open SQL within Visual Studio and insert the query below, and I click the "Verify SQL Syntax" button, I get two messages.:

    1st - The SQL syntax has been verified against data source.

    2nd - The Following Errors were encountered while parsing the contents of the SQL pane:

    The OVER SQL construct or statement is not supported.

    How do I fix this error?

    -- Procedure

    SELECT *

    FROM (

    SELECT ROW_NUMBER() OVER (ORDER BY Livros.LivroTitulo ASC) AS row,

    Livros.LivroId,

    Livros.LivroLojistaId,

    Livros.LivroStatusId,

    Livros.LivroMarcaId,

    Livros.LivroAutorId,

    Livros.LivroTitulo,

    Livros.LivroSubtitulo,

    Livros.LivroISBN13,

    Livros.LivroEAN13,

    Livros.LivroIdiomaId,

    Livros.LivroEstadoId,

    Livros.LivroAcabamentoId,

    Livros.LivroNumeroEdicao,

    Livros.LivroAnoPublicacao,

    Livros.LivroNumeroPaginas,

    Livros.LivroPrecoCusto,

    Livros.LivroPrecoCapa,

    Livros.LivroAliquotaIPI,

    Livros.LivroAliquotaICMS,

    Livros.LivroPeso,

    Livros.LivroAltura,

    Livros.LivroLargura,

    Livros.LivroImagemCapa,

    Livros.LivroResenha,

    Livros.LivroCriadoPorUsuarioId,

    Livros.LivroDataCadastro,

    Marcas.MarcaNome AS Editora,

    LivrosAutores.LivroAutorLivroId,

    Autores.AutorId,

    Autores.AutorNome AS Autor

    FROM Livros

    INNER JOIN Marcas ON Marcas.MarcaId = Livros.LivroMarcaId

    INNER JOIN LivrosAutores ON LivrosAutores.LivroAutorLivroId = Livros.LivroId AND LivrosAutores.LivroAutorAutorId = Livros.LivroAutorId

    INNER JOIN Autores ON Autores.AutorId = LivrosAutores.LivroAutorAutorId

    WHERE

    Livros.LivroTitulo LIKE 'só%') AS Tbl

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply