Global Function in 2005  
Author Message
Dolphe





PostPosted: Tue May 30 06:35:55 CDT 2006 Top

SQL Server Developer >> Global Function in 2005

Hi,

I'm trying to create a global function in SQL Server 2005. I mean, a
function similar to GETDATE(), that is public for all databases.

This is possible in SQL Server 2000, but I don't find any similar in
2005

Thanks in advance

--
--
--
--

Un saludo

--
--
----------------------------------------------
"Sólo sé que no sé nada. " (Sócrates)

SQL Server258  
 
 
Erland





PostPosted: Tue May 30 06:35:55 CDT 2006 Top

SQL Server Developer >> Global Function in 2005 Carlos Sacristán (csacristanARROBAmvpsPUNTOorg) writes:
> I'm trying to create a global function in SQL Server 2005. I mean, a
> function similar to GETDATE(), that is public for all databases.
>
> This is possible in SQL Server 2000, but I don't find any similar in
> 2005

I guess this was possible in SQL 2000 by creating functions in master and
make them look like system functions as fn_get_trace_status(). However,
that was entirely unsupported.

In SQL 2005, system procedures and system functions are stored in the
invisible resource database.


--


Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
 
 
Carlos





PostPosted: Tue May 30 07:09:06 CDT 2006 Top

SQL Server Developer >> Global Function in 2005 Thanks Edgar,

I know this was unsupported, but the applications that actually run
against SQL Server 2000 use this feature, so I trying to do the same in
2005. Do you know any way to get something similar?

I try with synonyms, but it's no possible

--
--
--
--

Un saludo

--
--
----------------------------------------------
"Sólo sé que no sé nada. " (Sócrates)



> Carlos Sacristán (csacristanARROBAmvpsPUNTOorg) writes:
> > I'm trying to create a global function in SQL Server 2005. I mean, a
> > function similar to GETDATE(), that is public for all databases.
> >
> > This is possible in SQL Server 2000, but I don't find any similar in
> > 2005
>
> I guess this was possible in SQL 2000 by creating functions in master and
> make them look like system functions as fn_get_trace_status(). However,
> that was entirely unsupported.
>
> In SQL 2005, system procedures and system functions are stored in the
> invisible resource database.
>
>
> --

>
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx


 
 
Erland





PostPosted: Tue May 30 08:43:32 CDT 2006 Top

SQL Server Developer >> Global Function in 2005 Carlos Sacristán (csacristanARROBAmvpsPUNTOorg) writes:
> I know this was unsupported, but the applications that actually run
> against SQL Server 2000 use this feature, so I trying to do the same in
> 2005. Do you know any way to get something similar?

Moral: don't rely on unsupported and undocumented behaviour.

> I try with synonyms, but it's no possible

Synonyms sounds as the best bet, but you would have to install them in
every database. And the functions can not operate on tables in the local
database.

You will have to back to the drawing-board, I guess.

--


Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
 
 
Carlos





PostPosted: Wed May 31 01:50:50 CDT 2006 Top

SQL Server Developer >> Global Function in 2005 Bad news, really...

In my case, I don't need the functions to operate with tables. There are
scalar function, for example, something like



RETURNS VARCHAR(8000)
AS
BEGIN

END

I think that the possibility to create this type of scalar-functions
(globals for all databases) could be an interesting feature.

Anyway, thanks for your help Erland


--
--
--
--

Un saludo

--
--
----------------------------------------------
"Sólo sé que no sé nada. " (Sócrates)



> Carlos Sacristán (csacristanARROBAmvpsPUNTOorg) writes:
> > I know this was unsupported, but the applications that actually run
> > against SQL Server 2000 use this feature, so I trying to do the same in
> > 2005. Do you know any way to get something similar?
>
> Moral: don't rely on unsupported and undocumented behaviour.
>
> > I try with synonyms, but it's no possible
>
> Synonyms sounds as the best bet, but you would have to install them in
> every database. And the functions can not operate on tables in the local
> database.
>
> You will have to back to the drawing-board, I guess.
>
> --

>
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx


 
 
Erland





PostPosted: Wed May 31 02:31:00 CDT 2006 Top

SQL Server Developer >> Global Function in 2005 Carlos Sacristán (csacristanARROBAmvpsPUNTOorg) writes:
> In my case, I don't need the functions to operate with tables. There
> are scalar function, for example, something like
>

> RETURNS VARCHAR(8000)
> AS
> BEGIN

> END
>
> I think that the possibility to create this type of scalar-functions
> (globals for all databases) could be an interesting feature.

On http://lab.msdn.microsoft.com/ProductFeedback/ you can submit a
suggestion for this to be added ot a future release of SQL Server.

--


Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx