What does a hyphen do in SQL?

Can varchar have hyphen?

what data type in SQL Server would allow me to use numbers and dashes (101-07, and stuff like that) in the field. Then you have to use a varchar = none numeric data type to store numeric with dashes.

All replies.

Alankar Chakravorty
Joined Dec 2009
1 9 Alankar Chakravorty’s threads Show activity

Can MySQL table name contains hyphen?

No, you won’t get any issues with underscores in a MySQL table name. You will get the issues with a dash in a MySQL table name.

Can you use a hyphen in SQL?

2 Answers. Yes, you can use punctuation, white space, international characters, and SQL reserved words if you use delimited identifiers: SELECT * FROM `my-table`;

Is hyphen a special character in SQL?

Under SQL-92 table and field names should not: Contain SQL special characters like the hyphen/dash/minus character. Start with non-alphabetic characters like the underscore.

How do I add a hyphen in SQL?

To set a string with hyphen and numbers, you need to use single quotes. For example, ‘Customer-1234-899’, ‘Customer-9383-901’, etc.

What data type is a hyphen?

1 Answer. With hyphens, it’s a string, full stop!

Can a table name start with underscore?

Underscores are perfectly legal in table names.

IT IS INTERESTING:  What will be the order of the data being sorted after the execution of given SQL query?

How do you make notes in SQL?

Comments Within SQL Statements

  1. Begin the comment with a slash and an asterisk (/*). Proceed with the text of the comment. This text can span multiple lines. …
  2. Begin the comment with — (two hyphens). Proceed with the text of the comment. This text cannot extend to a new line.

How do you check if a character is a hyphen?

The if statement checks if the character is not an underscore or a hyphen to then append it to the string variable word . But if it is a hyphen or an underscore then capitalize the first letter of word as that is the last appended character & the underscore or hyphen is not appended.

Which special characters are not allowed in SQL?

The use of special characters in regular identifiers is restricted. For example, a view name that begins with or consists only of numeric characters must be delimited because a regular identifier cannot begin with the characters 0 through 9, #, @, and $.

How do you insert special characters in SQL?

Solution 3

  1. select * from table where myfield like ‘%15% off%’ ESCAPE ”
  2. set @myString = replace( replace( replace( replace(@myString,”,’\’), ‘%’,’%’), ‘_’,’_’), ‘[‘,'[‘)
  3. select * from table where myfield like ‘%’ + @myString + ‘%’ ESCAPE ”
Categories PHP