Passing single input parameter with format 'test1', 'test2', 'test3' [duplicate] - sql

This question already has answers here:
Parameterize an SQL IN clause
(41 answers)
Closed 8 years ago.
My stored procedure has the following code:
WHERE tag IN (#InValue)
I want to send a list of tags as an input parameter
EXEC dbo.TestSelect #InValue = '''Test1'',''Test2'',''Test3'''
am I close?

I suggest taking a look at table valued parameters - these have been introduced in SQL Server 2008.
Table-valued parameters are a new parameter type in SQL Server 2008. Table-valued parameters are declared by using user-defined table types. You can use table-valued parameters to send multiple rows of data to a Transact-SQL statement or a routine, such as a stored procedure or function, without creating a temporary table or many parameters.

Related

Is it possible to create sp with an integer array parameter in Sql Server? [duplicate]

This question already has answers here:
How to pass an array into a SQL Server stored procedure
(13 answers)
Closed 2 years ago.
I want to call a stored procedure from a Web Api controller. As a parameter i need to pass id's of items to the sp but id count is not stable. For a case i may pass 3 ids for another it may be 10 ids. Is it possible to pass an array or list of numbers to a stored procedure.
Use a Table-Valued Parameter, JSON, or XML.

Concat function has not be run in Oracle SQL developer [duplicate]

This question already has answers here:
Function vs. Stored Procedure in SQL Server
(19 answers)
Closed 2 months ago.
When I run my whole SQL query then I got an error. CONCAT() function has not be run while execution:
..... concat(cast(col1 as varchar2(10)),'-', col2) = 'value'
Below this one is part of the query but I stuck on this line only. Why Concat function has not be run.
CONCAT function takes only 2 arguments. You must be getting invalid number of Arguments here.
Use
... col1||'-'||col2 = 'value'....
No need to explicitly cast your variable here. Oracle will implicitly handle this.

How to Check the given string is a reserved keyword in sql server [duplicate]

This question already has answers here:
Check if string is SQL Server Reserved Keywords or not
(3 answers)
Closed 8 years ago.
How to check whether the given string is a reserved keyword in sql server.
I checked a lot in google ,but i didn't find one!!
for eg: If i am giving the input String as 'Order',sql statement should
return whether it is reserved keyword.
Is there any built-in stored procedures or function to do this? Any help would be appreciated.
There is no built-in function to do that.
Here is the list of the known identifiers.
http://technet.microsoft.com/en-us/library/ms189822.aspx
I suggest to put these in an table and use it in a function / stored procedure.

DIFFERENCE in Linq [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Does Linq have "Difference"?
How to convert the following SQL Query to Linq
SELECT * FROM Designation WHERE DIFFERENCE(EmpDesg, ‘Engineer’) >= 3
You need to write a stored procedure and bring it into your context, define a user-defined function (if you're using EF) or you need to be willing to just execute a raw SQL query through the context. You can't access DIFFERENCE using LINQ to SQL directly (there is no LINQ query opeartor that will be translated into T-SQL DIFFERENCE).
Does Linq have "Difference"?
Summary:
Create User-Defined SQL Function
Add that function to your DBML diagram
Call that function in your WHERE clause

IS vs AS keywords for PL/SQL Oracle Function or Procedure Creation [duplicate]

This question already has answers here:
What is the difference between "AS" and "IS" in an Oracle stored procedure?
(6 answers)
Closed 9 years ago.
I have been trying to find out what the difference is between the IS and AS keywords in PL/SQL when creating an Oracle function or procedure.
I have searched and have been unable to find any information on this. Does anyone know the difference?
I've never known there to be a difference. The Oracle documentation implies that they are synonyms:
The function body begins with the keyword IS (or AS) and ends with the keyword END followed by an optional function name.
Same as DISTINCT and UNIQUE in select statements.
i.e, there is no material difference between 'IS' and 'AS'.
Backwards compatibility and meeting standards