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

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.

Related

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.

SQL Server - what does it mean `N'some string`? [duplicate]

This question already has answers here:
What does N' stands for in a SQL script ? (the one used before characters in insert script)
(7 answers)
Closed 5 years ago.
What does it mean N'some string' in SQL Server. I mean if I can use it to prevent against SQL Injection?
For example:
... LIKE N'%somePattern%'
Is SQL Injection safe ?
The N has nothing to with SQL injection. You need to use it when you use unicode data
From msdn:
Prefix Unicode character string constants with the letter N. Without
the N prefix, the string is converted to the default code page of the
database. This default code page may not recognize certain characters.
It means the string is an nchar as opposed to a char (see What is the difference between char, nchar, varchar, and nvarchar in SQL Server?)
It's purely about the datatype - nothing to do with SQL injection at all.

Create custom configuration functions in SQL SERVER [duplicate]

This question already has answers here:
Create a global static variable in SQL Server?
(4 answers)
Closed 9 years ago.
I want a function similar to ##servername to be created. So, the new ##mycustomname will return something I set up and then I can use ##mycustomname in my deployed T-SQL Scripts.
Is there a way to do it?
No you can't. These are reserved keywords.
What you want to be somewhat equivalent to global variables, which unfortunately does not exists.
The best you can do is declare a function.

What does a colon (':') mean in SQL syntax? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What does the colon sign “:” do in a SQL query?
Simple SQL question:
What does : stand for?
For example:
SELECT * FROM myTable
WHERE Employee_column = :P_EmplId;
The : isn't exactly easy to google when you don't know what this is called. Even searching here didn't help. I'm using Oracle 11g if that makes any difference.
It is a bind variable:
A placeholder in a SQL statement that must be replaced with a valid
value or value address for the statement to execute successfully. By
using bind variables, you can write a SQL statement that accepts
inputs or parameters at run time. The following example shows a query
that uses v_empid as a bind variable:
Most likely you took the query from a template. It is meant to be processed with php's MDB2 sql framework. The ":" (colon) signals a placeholder in the statement, meant to be replaced when the query is executed.

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