Saturday, July 2, 2011

SQL SERVER - UDF - Get Name as per specific format

Following Sql function can be used to get Name as per specific format

--This function uses table employee of pubs database which comes with sql server


CREATE FUNCTION [dbo].fnEmployeeName(@ID varchar(15), @Format int = 1) RETURNS varchar(30) AS

/****** fnEmployeeName******/

-- Return Employee Name as per the required format

BEGIN
DECLARE @FIRSTNM varchar(15), @LASTNM varchar(15), @MIDDLENM varchar(15)
SELECT @FIRSTNM = fname, @LASTNM = lname, @MIDDLENM = minit FROM employee WHERE emp_id = @ID
DECLARE @Value varchar(103) IF @@ROWCOUNT > 0
begin
IF @Format=1 SET @Value = LTRIM(IsNull(@LASTNM,'') + IsNull(' ' + @FIRSTNM,'') + IsNull(' ' + @MIDDLENM,''))
Else
SET @Value = LTRIM(IsNull(@FIRSTNM,'') + IsNull(' ' + @LASTNM,'') + IsNull(' ' + @MIDDLENM,'')) END
RETURN @Value
END

No comments:

Post a Comment

Your project is not referencing the "MonoAndroid,Version=v8.1" framework. Add a reference to "MonoAndroid,Version=v8.1" in the "frameworks" section of your project.json, and then re-run NuGet restore.

I had  the same problem. Reason: file obj/project.assets.json target "MonoAndroid,Version=v7.1" when my project target androi...