Type of the parameters passing in stored procedure - stored-procedures

how to check a parameter is string or number in stored procedure??
based on the incoming parameter type I want to work on the functionality
for example: if string i will search by name, if the number I will search by phone number

Please try below whether this is helpful.
Check your input parameter using below sample function ISNUMERIC and if it returns 1 then it is numeric value. In your case it is phone number. else it is address.
SELECT ISNUMERIC('4567');

Related

Excel Power Query: Passing parameter to oDataFeed URL throws error

When a direct number for the TestPlanID is given it works.
When passing the value from sheet to a Query and then appending it to URL throws an error.
Expression.Error: We cannot apply operator & to types Text and Number.
Details:
Operator=&
Left=https://analytics.dev.azure.com/OrgName/ProjName/_odata/v3.0-preview/TestPoints?$apply=filter((TestSuite/TestPlanId eq
Right=39128
Can you try
eq"""&varTPID&"""
If value of varTPID is an integer/decimal, can you change the first line in power query to varTPID=Text.From(varTestPlanID) and then use eq"""&varTPID&"""
Also I think, TestPoints?"&"$apply needs to be changed to TestPoints?$apply

How do i remove rows based on comma-separated list of values in a Power BI parameter in Power Query?

I have a list of data with a title column (among many other columns) and I have a Power BI parameter that has, for example, a value of "a,b,c". What I want to do is loop through the parameter's values and remove any rows that begin with those characters.
For example:
Title
a
b
c
d
Should become
Title
d
This comma separated list could have one value or it could have twenty. I know that I can turn the parameter into a list by using
parameterList = Text.Split(<parameter-name>,",")
but then I am unsure how to continue to use that to filter on. For one value I would just use
#"Filtered Rows" = Table.SelectRows(#"Table", each Text.StartsWith([key], <value-to-filter-on>))
but that only allows one value.
EDIT: I may have worded my original question poorly. The comma separated values in the parameterList can be any number of characters (e.g.: a,abcd,foo,bar) and I want to see if the value in [key] starts with that string of characters.
Try using List.Contains to check whether the starting character is in the parameter list.
each List.Contains(parameterList, Text.Start([key], 1)
Edit: Since you've changed the requirement, try this:
Table.SelectRows(
#"Table",
(C) => not List.AnyTrue(
List.Transform(
parameterList,
each Text.StartsWith(C[key], _)
)
)
)
For each row, this transforms the parameterList into a list of true/false values by checking if the current key starts with each text string in the list. If any are true, then List.AnyTrue returns true and we choose not to select that row.
Since you want to filter out all the values from the parameter, you can use something like:
= Table.SelectRows(#"Changed Type", each List.Contains(Parameter1,Text.Start([Title],1))=false)
Another way to do this would be to create a custom column in the table, which has the first character of title:
= Table.AddColumn(#"Changed Type", "FirstChar", each Text.Start([Title],1))
and then use this field in the filter step:
= Table.SelectRows(#"Added Custom", each List.Contains(Parameter1,[FirstChar])=false)
I tested this with a small sample set and it seems to be running fine. You can test both and see if it helps with the performance. If you are still facing performance issues, it would probably be easier if you can share the pbix file.
This seems to work fairly well:
= List.Select(Source[Title], each Text.Contains(Parameter1,Text.Start(_,1))=false)
Replace Source with the name of your table and Parameter1 with the name of your Parameter.

In QUERY on unique values, NO_COLUMN error

I have a list of U.S. states where duplicate values are also available. I need to find how many unique states are there in a list.
'Unique' function returns all the unique states but in conjunction with 'query' function the following error message is returned:
Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: A
=query(unique(A3:A26),"Select count(A)")
What am I doing wrong?
Having reconstructed the data (after UNIQUE it is different) you can't then continue with letters for column references. So:
=query(unique(A3:A26),"Select count(Col1)")

How to handle number format of OData Edm.Decimal in sapui5 correct?

It looks like OData sends Edm.Decimal as "String" also containing the decimal separator.
Question: What should be send by OData? Always the same values (for example separator with ".")?
Question: How can this data be bound to SAPUI5 control with an automatic locale handling?
I am already using
new sap.ui.model.resource.ResourceModel({
But numbers are always shown with a dot as separator.
I think there is a bug in sap.ui.model.type.Float implementation.
You can use that data type to format decimal values.
But if you try to change the value and store it back, data will be of type float. But for OData it must be a String.
Debugging the method parserValue gives me the hint:
case "string":
iResult = this.oFormat.parse(oValue);
... error handling ...
return iResult;
The iResult will not be transformed to a String if it is not already a string. You can override that method and ensure that it will return a string.

What is the difference between AsInteger and Value in Delphi?

I want to know the difference between following two statements related to datasets in delphi.
dsMyDataSet.ParamByName('ID').AsInteger := 1122; //If ID is integer
dsMyDataSet.ParamByName('ID').AsString := '1122'; //If ID is string
and
dsMyDataSet.ParamByName('ID').Value := 1122; //ID is string or integer
Do these statements carry same meaning? Does "value" implicitly converts integer into string?
The TParam.AsInteger property, for instance, set the value and the data type of the parameter. TParam.Value does the same, but TParam will decide which type will be mapped to the value inside the Variant and not always it´s the data type you would like.
I advise you to set values by using the AsXXX properties only, since you will be in control of the parameter's data type, what can save you from having parameter binding errors.
So, answering your final question: no, the values won´t be converted to the right data type, you have to set the data type by selecting the right property to assign the value.

Resources