Visual studio feeds

All Visual Studio blogs in one place

Subscribe

Enter your email address:

Delivered by FeedBurner

Increase your website traffic with Attracta.com

Google+

Contact

Email:
Subject:
Message:
Anti-spam: How many eyes has a typical person?

Follow us on FB

Search

T-SQL Tips: Can a UDF Return Values of Multiple Datatypes?

AddThis Social Bookmark Button
This was a question raised in one of the forums recently.
This blog explains how we can create a user defined function (UDF) which can return values of different datatypes under different conditions.
Consider the case where we require creating a user defined function which based on the conditions have to return values of different data types. Since a user defined function can have only a single datatype for the return value we need to find a datatype which can store values for different data types. There's a datatype available in SQLServer called sql_variant which can be used
for this purpose

As per MSDN sql_variant is :-

A data type that stores values of various SQL Server-supported data types.

https://msdn.microsoft.com/en-us/library/ms173829.aspx

So we can utilize sql_variant datatype as the return value for the user defined function which will have the ability to store and return values for all the SQLServer supported datatypes

As an illustration we can consider a user defined function as below

ALTER FUNCTION dbo.TestVariant
(
@Mode char(1)
)
RETURNS sql_variant
AS
BEGIN
DECLARE @Ret sql_variant
IF @Mode = 'i'
SELECT @Ret = 1
ELSE IF @Mode = 'v'
SELECT...(Read whole news on source site)

Visual Studio Team Services Bug Tracker with HockeyApp for Universal Windows Apps

AddThis Social Bookmark Button
You can use HockeyApp to create bugs for crash reports and track feedback in several bug tracking systems directly.  In this post we will see how we can create crash issues as defect in Visual Studio Team Services.  The configuration steps are quite simple and can be achieved by following below steps. Before your precede [...]

Understanding Database Scalability – Vertical and Horizontal

AddThis Social Bookmark Button
Since I have started my consulting engagements with customers around the world, I have been asked interesting queries from time to time. In a recent customer call, the customer insisted I assist them in taking a call on if they need to buy one server with 64 cores or if they need to buy 2 servers of 32 cores. I had to explain that it is always not that simple to answer the same. After close to 30 mins of conversation they understood finally what I was talking. I took a moment to blog about this engaging conversation about database

施設基準に達してる病院の禁煙治療で肺がんのリスク減

AddThis Social Bookmark Button
喫煙の危険性は、肺がんなどの発症のリスクが上昇してしまうことなどで知られています。 肺がん以外にも呼吸器疾患などの発症率が高まることによって、体への健康被害が大きいものと考えられています。 肺がんの発症リスクについては、...続きを読む 投稿施設基準に達してる病院の禁煙治療で肺がんのリスク減禁煙を開始して体を健康に!の最初に登場しました。

Home