Single quotes are used to indicate the beginning and end of a string in SQL. Double quotes generally aren't used in SQL, but that can vary from database to database.
Stick to using single quotes.
That's the primary use anyways. You can use single quotes for a column alias - where you want the column name you reference in your application code to be something other than what the column is actually called in the database. For example: PRODUCTS.id would be more readable as product_id, so you use either of the following:
Recently I needed to create a Named Calculation in SQL Server Analysis Services (SSAS) called Full Name. To accomplish this I combined First Name and Last Name columns, and added the space between first and last using Single Quotes as in
FirstName+’ ‘+LastName
This got me thinking “When do you use single quotes and when do you use double quotes to represent literal strings in SSIS, SSRS, and SSAS?” My first introduction to the Microsoft BI Stack was to T-SQL which uses single quotes for string literals. As I researched this question and verified my findings with a SQL MVP I found that Double Quotes were the dominant arrangement. Single Quotes were only used anywhere T-SQL is used such as Execute SQL and Stored Procedures and Single
Quotes were also used in Named Calculations in SSAS. Outside of these two areas it appears everything else is Double Quotes: script tasks, expressions, and the like.
It is also my understanding that you can even change the setup of T-SQL to accept Double Quotes. If anyone has further input I would gladly invite it.
Single quotes are used to indicate the beginning and end of a string in SQL. Double quotes generally aren't used in SQL, but that can vary from database to database.
Stick to using single quotes.
That's the primary use anyways. You can use single quotes for a column alias - where you want the column name you reference in your application code to be something other than what the column is actually called in the database. For example: PRODUCTS.id would be more readable as product_id, so you use either of the following:
Recently I needed to create a Named Calculation in SQL Server Analysis Services (SSAS) called Full Name. To accomplish this I combined First Name and Last Name columns, and added the space between first and last using Single Quotes as in
FirstName+’ ‘+LastName
This got me thinking “When do you use single quotes and when do you use double quotes to represent literal strings in SSIS, SSRS, and SSAS?” My first introduction to the Microsoft BI Stack was to T-SQL which uses single quotes for string literals. As I researched this question and verified my findings with a SQL MVP I found that Double Quotes were the dominant arrangement. Single Quotes were only used anywhere T-SQL is used such as Execute SQL and Stored Procedures and Single
Quotes were also used in Named Calculations in SSAS. Outside of these two areas it appears everything else is Double Quotes: script tasks, expressions, and the like.
It is also my understanding that you can even change the setup of T-SQL to accept Double Quotes. If anyone has further input I would gladly invite it.
การแปล กรุณารอสักครู่..