Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sp-executesql-transact-sql.md #9823

Open
wants to merge 1 commit into
base: live
Choose a base branch
from

Conversation

bpd0018
Copy link
Contributor

@bpd0018 bpd0018 commented Jun 20, 2024

There are way more than 12 statements generated. You get one statement for each year and month combination for each language where the first 3 characters of the month name are different.

Personally, I think you would be better off using a table naming scheme that is not locale dependent like 'Sales_' +
cast(datepart(yy, @PrmOrderDate) as char(4)) +
'_' +
cast(datepart(mm, @PrmOrderDate) as char(2))

To see the table names that you get now, run the following ...

DECLARE @PrmOrderDate DATETIME;
SET LANGUAGE N'us_english';
SET @PrmOrderDate = '01/31/2021'; -- set date here because the date literal format also depends on LANGUAGE SELECT SUBSTRING(DATENAME(mm, @PrmOrderDate), 1, 3) + CAST(DATEPART(yy, @PrmOrderDate) AS CHAR(4)) + 'Sales'; SET LANGUAGE N'Español';
SELECT SUBSTRING(DATENAME(mm, @PrmOrderDate), 1, 3) + CAST(DATEPART(yy, @PrmOrderDate) AS CHAR(4)) + 'Sales'; SET LANGUAGE N'ελληνικά';
SELECT SUBSTRING(DATENAME(mm, @PrmOrderDate), 1, 3) + CAST(DATEPART(yy, @PrmOrderDate) AS CHAR(4)) + 'Sales';

There are way more than 12 statements generated. You get one statement for each year and month combination for each language where the first 3 characters of the month name are different.

Personally, I think you would be better off using a table naming scheme that is not locale dependent like
'Sales_' +
cast(datepart(yy, @PrmOrderDate) as char(4)) +
'_' +
cast(datepart(mm, @PrmOrderDate) as char(2))

To see the table names that you get now, run the following ...

DECLARE @PrmOrderDate DATETIME;
SET LANGUAGE N'us_english';
SET @PrmOrderDate = '01/31/2021'; -- set date here because the date literal format also depends on LANGUAGE
SELECT SUBSTRING(DATENAME(mm, @PrmOrderDate), 1, 3) + CAST(DATEPART(yy, @PrmOrderDate) AS CHAR(4)) + 'Sales';
SET LANGUAGE N'Español';
SELECT SUBSTRING(DATENAME(mm, @PrmOrderDate), 1, 3) + CAST(DATEPART(yy, @PrmOrderDate) AS CHAR(4)) + 'Sales';
SET LANGUAGE N'ελληνικά';
SELECT SUBSTRING(DATENAME(mm, @PrmOrderDate), 1, 3) + CAST(DATEPART(yy, @PrmOrderDate) AS CHAR(4)) + 'Sales';
Copy link
Contributor

@bpd0018 : Thanks for your contribution! The author(s) have been notified to review your proposed change.

Copy link
Contributor

Learn Build status updates of commit c7ad5bc:

✅ Validation status: passed

File Status Preview URL Details
docs/relational-databases/system-stored-procedures/sp-executesql-transact-sql.md ✅Succeeded

For more details, please refer to the build report.

For any questions, please:

@Court72
Copy link
Contributor

Court72 commented Jun 20, 2024

@markingmyname

Can you review the proposed changes?

Important: When the changes are ready for publication, adding a #sign-off comment is the best way to signal that the PR is ready for the review team to merge.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

@prmerger-automator prmerger-automator bot added the aq-pr-triaged tracking label for the PR review team label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants