Tuesday, March 27, 2012

CONCAT function

Apologies for the glib answer but the concatinate function
you are looking for is the '+' that you already have.
The function that you are talking about (CONCAT) will work
however unless you are going to have a different number of
parameters then its not really worth it, and even then you
will need a bit of fancy code.
If it is then go ahead, but there is not a built in one.
if you have any further questions then please feel fee to
email me at peternolan67@.REMOVETHIS@.hotmail.com
Peter
Adam and Eve had many advantages but the principal one was
that they escaped teething.
Mark Twain

>--Original Message--
>Does SQL Server 2000 support the CONCAT SQL function?
>For example:
>-> 'SQLServer'
>I know it can be written as this:
>SELECT 'SQL' + 'Ser' + 'ver';
>
>My thoughts are to create a user-based function called
CONCAT. Are other
>thoughts on this?
>Thanks!
>.
>
I tried to write this user-based function called CONCAT, yet is not working
properly. Only the first character is returned.
CREATE FUNCTION CONCAT (@.string1 nvarchar, @.string2 nvarchar)
RETURNS nvarchar AS
BEGIN
DECLARE @.fullstring nvarchar;
SELECT @.fullstring = @.string1 + @.string2;
return @.fullstring;
END
select dbo.concat('aaaa','bbbb')

> 'a'
"Peter The Spate" wrote:

> Apologies for the glib answer but the concatinate function
> you are looking for is the '+' that you already have.
> The function that you are talking about (CONCAT) will work
> however unless you are going to have a different number of
> parameters then its not really worth it, and even then you
> will need a bit of fancy code.
> If it is then go ahead, but there is not a built in one.
> if you have any further questions then please feel fee to
> email me at peternolan67@.REMOVETHIS@.hotmail.com
> Peter
> Adam and Eve had many advantages but the principal one was
> that they escaped teething.
> Mark Twain
>
> CONCAT. Are other
>
|||You have to define a length for the nvarchar variables
/*for example*/
@.string1 nvarchar(100)
Keith
"Bevo" <Bevo@.discussions.microsoft.com> wrote in message
news:8E24AC41-ECE8-4E96-A716-5700F2C5BE50@.microsoft.com...
> I tried to write this user-based function called CONCAT, yet is not
working[vbcol=seagreen]
> properly. Only the first character is returned.
> CREATE FUNCTION CONCAT (@.string1 nvarchar, @.string2 nvarchar)
> RETURNS nvarchar AS
> BEGIN
> DECLARE @.fullstring nvarchar;
> SELECT @.fullstring = @.string1 + @.string2;
> return @.fullstring;
> END
>
> select dbo.concat('aaaa','bbbb')
>
> "Peter The Spate" wrote:
|||I granted execute to a user called ENTRY, yet the user has to explicit state
the owner when making the call:
This fails:
select concat('a','b')
Server: Msg 195, Level 15, State 10, Line 1
'concat' is not a recognized function name.
This works
select dbo.concat('a'b')

>ab
How do I allow the user to use the dbo owned function without specifying the
owner?
Thanks!
"Keith Kratochvil" wrote:

> You have to define a length for the nvarchar variables
> /*for example*/
> @.string1 nvarchar(100)
> --
> Keith
>
> "Bevo" <Bevo@.discussions.microsoft.com> wrote in message
> news:8E24AC41-ECE8-4E96-A716-5700F2C5BE50@.microsoft.com...
> working
>
|||> How do I allow the user to use the dbo owned function without specifying the
> owner?
You cannot. The must specify the owner and function name in order to use
a user defined function.
Gert-Jan
|||Books Online states this:
If an object is not qualified with the object owner when it is referenced
(for example, my_table instead of owner.my_table), SQL Server looks for an
object in the database in the following order:
Owned by the current user.
Owned by dbo.
According to this, the dbo function should be found. I this documentation
not correct?
"Gert-Jan Strik" wrote:

> You cannot. The must specify the owner and function name in order to use
> a user defined function.
> Gert-Jan
>
|||However, user definined functions are a special case, different from other
objects. ALL user defined functions must include the owner name, even if it
is the current user.
Please read about User Defined Functions in the Books Online.
HTH
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Bevo" <Bevo@.discussions.microsoft.com> wrote in message
news:CA4058D0-9569-4602-AB81-BB525A75456E@.microsoft.com...[vbcol=seagreen]
> Books Online states this:
> If an object is not qualified with the object owner when it is referenced
> (for example, my_table instead of owner.my_table), SQL Server looks for an
> object in the database in the following order:
> Owned by the current user.
> Owned by dbo.
>
> According to this, the dbo function should be found. I this documentation
> not correct?
>
> "Gert-Jan Strik" wrote:
specifying the[vbcol=seagreen]
|||Is there any workaround to this? Can I trick the database into thinking this
is a system function?
"Kalen Delaney" wrote:

> However, user definined functions are a special case, different from other
> objects. ALL user defined functions must include the owner name, even if it
> is the current user.
> Please read about User Defined Functions in the Books Online.
> --
> HTH
> --
> Kalen Delaney
> SQL Server MVP
> www.SolidQualityLearning.com
>
> "Bevo" <Bevo@.discussions.microsoft.com> wrote in message
> news:CA4058D0-9569-4602-AB81-BB525A75456E@.microsoft.com...
> specifying the
>
>
|||No, the system functions are actually not objects in the normal sense. They
are almost like built in commands: substring, getdate, power, etc. The
system functions do not exist in any system tables, and their definitions
are not available in the TSQL language. There is no way to have the names
you give your UDFs be recognized by the parser, unless you get in and change
SQL Server's source code. In fact, supplying the owner name the way the
parser can tell that you are indicating a UDF, and not something else, like
a system function. Leaving off the owner name makes the parser think you are
specifying a system function, but then it realizes it has no built in
function of that name, so you get the error.
HTH
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Bevo" <Bevo@.discussions.microsoft.com> wrote in message
news:7AEA29F7-74D3-468A-9711-4829E36C3437@.microsoft.com...
> Is there any workaround to this? Can I trick the database into thinking
this[vbcol=seagreen]
> is a system function?
> "Kalen Delaney" wrote:
other[vbcol=seagreen]
it[vbcol=seagreen]
referenced[vbcol=seagreen]
for an[vbcol=seagreen]
documentation[vbcol=seagreen]
use[vbcol=seagreen]

No comments:

Post a Comment