Re: Dinamyc Function



aCe (acerahmat@xxxxxxxxx) writes:
i want to make a FN that can check record exist or not.
this is my FN:
CREATE FUNCTION ufnCheckExists(
...
error msg :
Msg 1087, Level 15, State 2, Procedure ufnCheckExists, Line 25
Must declare the table variable "@table".

is it possible to create it. or any suggestion.
my purpose to create this, is i can reuse my function without creating
ambiguous function.

Simply forget it. This is T-SQL, this is not C#. While code reuse is a
virtue in T-SQL, it is not as big virtue as in an traditional programming
langauge. Specifically, it's very rarely a good idea to parameterise on
the table name.

For a longer discussion on dynamic SQL, see this article on my web
site: http://www.sommarskog.se/dynamic_sql.html.



--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

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
.



Relevant Pages

  • Re: STORED PROCEDURE - passing table name as a parameter
    ... T-SQL, is that you get problems if the view definition does not fit into ... will need to query other system tables, for instance syscolumns. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Cant create new query
    ... Books Online is a pretty good start; most of the books I have for T-SQL are ... the visual designers) will teach you all kinds of bad habits. ... tables and then copy-paste into SQL Server ...
    (microsoft.public.sqlserver.tools)
  • Re: Flattening Parent Child, an issue, please help
    ... AND t2.WBS_LEVEL = 2 LEFT OUTER JOIN ... I am using SQL Server 2000 with SP4. ... For information about dyamic SQL from T-SQL see ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Scripting Databases
    ... Basically, if I want to script a number of tables, I can right hand ... Again, T-SQL ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Multiuser Interface on shared servicer with SQL Backend
    ... There is one copy of an mde file on a server. ... SQL server, but there is only one mde file. ... "Keith Wilby" wrote: ... It's already split by virtue of the fact that it has a FE & BE. ...
    (microsoft.public.access.modulesdaovba)

Loading