Hi,
Well... I use SQL Server 2005, and I did not see this error (and the query
you gave is successfully executed on my server, whatever the database I
select), and I'm glad to get the comment from the database I reverse in a
new model...
What is the version of your server ?
Marc.
"Jerry M" <***@retalix.com> wrote in message news:***@forums-1-dub...
Thanks to those who tried to help. Here is the issue and solution for
anyone else who has this problem. The statement:
(select convert(varchar(8000), value) from ::fn_listextendedproperty(NULL,
''user'', u.name, ''table'', o.name, null, null) where name =
''MS_Description'')
is both bad and unnecessary. It is trying to do a "select ... where name
=", but name is not a selected variable. The fn_ function does not accept
qualified names (or apparently parameterized names). Basically I could not
resolve the errors in this line. However, all it is doing is trying to pull
a comment that could only exist in the database if it was created by a
recent version of Power Designer and then only if you actually put a comment
in the table. Then all you get is the comment. As I said, it is
unnecessary to the Reverse Engineering process because you are not likely to
be reverse engineering a database you created.
If you take the statement out (and remove the comma at the end of the case
statement), reverse engineering starts to work. You can do this by going
into Tools | Resources | DBMS and editing the MS SQL Server 2005 Properties.
Under Scripts | Objects | Table | SqlListQuery you will find the script that
generates the SQL below. Remove the text from the comma following the end
of the case statement to the end of the next line and save it.
You have to do one more thing to fully get Reverse Engineering working. The
SQL to get the column data was doing the same unnecessary thing and had
exactly the same problem. Under Scripts | Objects | Column | SqlListQuery
you will find the script that generates the SQL for extracting the Column
information during the Reverse Engineering process. In this case, just find
the line that starts:
(select convert(varchar(8000), value) from ::fn_listextendedproperty...
and remove that whole line. Because of the order of the returned values I
was concerned that I would have a problem, but it worked for me. I think
the rest of the stuff that was trying to be returned is not in most older
database and not really needed to get the structure and data elements you
are really looking for.
Anyhow these fixes allowed me to reverse engineer several older databases
just fine. I will leave this to whoever wants if they care to submit this
to Support to get a permanent fix. (Maybe someone will actually test it
before release. Sorry for the sarcasm, but this clearly was never run after
it was written.)
Jerry
"Jerry M" <***@retalix.com> wrote in message news:461671fa$***@forums-1-dub...
Here is more information on my problem. I turned on a trace in SQL Server
and was able to trap the statement that failed the "prepare". Here it is:
declare @p1 int
set @p1=NULL
exec sp_prepexec @p1 output,NULL,N'select
u.name,
o.name,
case (o.type) when ''S'' then ''SYSTEM TABLE'' else ''TABLE'' end,
(select convert(varchar(8000), value) from
::fn_listextendedproperty(NULL, ''user'', u.name, ''table'', o.name, null,
null) where name = ''MS_Description'')
from
sys.sysobjects o
join sys.schemas u on (u.schema_id = o.uid)
where
o.type in (''U'', ''S'')
and u.name = ''dbo''
order by 1, 2'
select @p1
The error message is
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'u'.
Msg 8180, Level 16, State 1, Procedure sp_prepexec, Line 1
Statement(s) could not be prepared.
I am not that good at SQL to understand the syntax issue plus the fix needs
to be in how this statement is being generated.
Thanks for any help
Jerry
"Jerry M" <***@retalix.com> wrote in message news:46166bdd$***@forums-1-dub...
When I try to Reverse Engineer any database on my MS SQL Server 2005 I get
the following error. This occurs even on databases created by
PowerDesigner.
Unable to list the tables.
[Microsoft][ODBC SQL Server Driver]{SQL Server}Statement(s) could not be
prepared.
SQLSTATE = 37000
This occurs when Reverse engineering starts up and when I select any
database and select any of the following tabs:
Table, View (but it returns views), System Table, Trigger
It sounds like some things in my DBMS Resource for Microsoft SQL Server 2005
(sqlsv2k5.xdb) are causing an ill-formed statement to be passed to the
engine. I tried pointing to the original, unmodified version of the .xdb
that came with the installation and I still get this message. Any ideas how
I might narrow down the problem and resolve it?