Re: Two issues with defncopy

"James K. Lowden" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
On Thu, 3 Jul 2014 09:29:58 -0500
Nem W Schlecht <[email protected]> wrote:

> Since syscomment is a deprecated table, defncopy really should be
> updated to to use either:
>      EXEC sp_helptext 'procowner.procname';
> or
>      SELECT OBJECT_DEFINITION(OBJECT_ID('procowner.procname'))

Hello Nem, and thanks for your careful work.  

When defncopy was new, SQL Server 2005 was still in the future.
Selecting from syscomments is what Sybase's utility did (and would
still have to do on Sybase servers).  

As I remember, a word could be split across two rows.  The logic should
probably leave (at least one of) the trailing blanks in place, and
stitch the rows together.  

Agreed OBJECT_DEFINITION is a better choice now if available.  defncopy
could probe for it and fall back on syscomments if it's not there.
That's would be a service to the FreeTDS community and more worthwhile
than fixing the 0.5% errors associated with syscomments.  

In re UTF-8, I have to guess some of your DDL contains non-ASCII
characters, and defncopy assumes a character is 1 byte.  Your 2x fix
will work until someone has column names in ancient Chinese.  Han
Dynasty objects never fail to surprise.  

Happy hacking.  

--jkl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.