all groups > sql server programming > november 2003 >
You're in the

sql server programming

group:

To all you SQLServer guru 's out there


Re: To all you SQLServer guru 's out there Kalen Delaney
11/7/2003 1:08:33 PM
sql server programming:
Why are making the parameter a character and not an integer?
It will return 'Name' for any value greater than '10000' ALPHABETICALLY,

so select dbo.Units('9')
will return 'Name'.
If that's what you want, fine.....

--
HTH
----------------
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com


[quoted text, click to view]

Re: To all you SQLServer guru 's out there Anith Sen
11/7/2003 2:38:50 PM
Note the changes:

CREATE FUNCTION dbo.Units
(@Sect CHAR(20)) --- define a length, default is 1
RETURNS VARCHAR (20)
AS
BEGIN
RETURN (CASE WHEN @Sect >= '10000' THEN 'Name' END)
END

Usage:
SELECT dbo.Units('10000');

--
- Anith
( Please reply to newsgroups only )

Re: To all you SQLServer guru 's out there Anith Sen
11/7/2003 3:29:38 PM
There is no challenge in here. Read the topic on CASE expressions in SQL
Server Books Online. Change all the character compatible datatype
declarations to include the length as mentioned before. You can do it
yourself, without resorting to Newsgroup support now. If you still have
trouble, please post back.

--
- Anith
( Please reply to newsgroups only )

To all you SQLServer guru 's out there GVE
11/7/2003 9:30:56 PM
Hi,

Could you help me with this function. I am new to SQLServer programming
This fynction is supposed to do the following.
if Sect >= 10000 return the string 'Name'.

The function does not work. What am I doing wrong


Regards
Guno

CREATE FUNCTION dbo.Units(@Sect char)
RETURNS varchar (20)
AS
BEGIN
Declare @Units varchar(20)

if (@Sect >= '10000')
SET @Units = 'Name'

Return (@Units)

END



Re: To all you SQLServer guru 's out there GVE
11/7/2003 9:59:30 PM
Hi Anith,
That was quick
Thank you very much

Regards
Guno
"Anith Sen" <anith@bizdatasolutions.com> schreef in bericht
news:uVUJp8WpDHA.3320@tk2msftngp13.phx.gbl...
[quoted text, click to view]

Re: To all you SQLServer guru 's out there GVE
11/7/2003 10:21:28 PM
Hi,

Could you also help me with this challenge.

Regards

Guno



CREATE FUNCTION dbo.Turnover( @Buscod char, @trntyp char, @Mpursecdeal
int, @Sectdeal int, @Msectdeal int, @Tos char )

Declare @TurnOver char

RETURNS char

AS

BEGIN

IF (@ Buscod = between (01 and 08) AND Trntyp = "A")

SET @TurnOver ="Budget "

IF (@ Buscod = 11 AND Trntyp = "D")

SET @TurnOver ="Option "

IF (@ Buscod = 20 AND Mpursecdeal = Sectdeal)

SET @TurnOver ="fixed"

IF (@ Buscod = XA AND Trntyp = "D" AND Mpursecdeal = Msectdeal)

SET @TurnOver ="revolving"

IF (@ Buscod = 01 AND Trntyp = "B" AND Msectdeal Between 1000 AND
2000)

SET @TurnOver ="Retailer"

RETURN(@TurnOver)

END



"GVE" <g.vanengel@chello.nl> schreef in bericht
news:#cOkL4WpDHA.2592@TK2MSFTNGP10.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button