SQL Server Functions

Source: Internet
Author: User

1. Functions

If exists (

Select *

From DBO. sysobjects

Where id = object_id (n' [DBO]. [get_ii_list] ')

And xtype in (n'fn ', n'if', n'tf ')

)

Drop function [DBO]. [get_ii_list]

Go

 

Create Function get_ii_list

(

)

Returns varchar (800)

As

 

Begin

Declare @ s varchar (800)

Set @ s =''

Select @ s = ',' + isnull (name, '') + @ s

From II

If (LEN (@ s)> 1)

Set @ s = right (@ s, Len (@ s)-1)

Return @ s

End

Go

 

**************************************** ******************

Select DBO. get_ii_list ()

--------------------- Result ---------------------------

Bin, Jack, hung, way, Danny

 

 

―――――――――――――――――

If exists (

Select * From DBO. sysobjects

Where id = object_id (n' [DBO]. [is_all_number] ')

And xtype in (n'fn ', n'if', n'tf ')

)

Drop function [DBO]. [is_all_number]

Go

 

Create Function is_all_number (

@ In varchar (10)

)

Returns integer

As

Begin

Declare @ I integer,

@ L integer,

@ C char

Set @ l = Len (@ in)

If (@ l <= 0)

Return 0

Set @ I = 1

While (@ I <= @ l)

Begin

Set @ C = substring (@ in, @ I, 1)

If (@ C <'0' or @ C> '9 ')

Return 0

Set @ I = @ I + 1

End

 

Return 1

End

Go

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.