Viewing 15 posts - 9,526 through 9,540 (of 10,143 total)
You will need to cast your return value as CHAR (or VARCHAR) if you want an embedded non-numeric character:
[font="Courier New"]DECLARE @weekNum INT, @WeekName CHAR(7)
SET @weekNum = 200843
SET @WeekName = STUFF(CAST(@weekNum...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 24, 2008 at 8:49 am
Hi Ram
I'm not exactly sure what you're looking for: whether it's start and end date in the same row to get the days difference between the two, or to perform...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 24, 2008 at 8:12 am
Hi b_boy
The part in bold is evaluating to zero for some rows:
(100.*
sum(case datepart(yy,t.orderdate) when 2008 then 1. else 0. end) /
...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 24, 2008 at 5:36 am
Madhivanan, quite right! I don't know why the conversion I posted is being used - possibly from a previous version. It's used extensively here to generate a suffix for export...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 24, 2008 at 5:22 am
SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 102), '.', '')
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 24, 2008 at 5:10 am
You're welcome Gareth, many thanks for the feedback.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 23, 2008 at 8:34 am
Hi Gareth
A really useful habit to get into is to always SELECT whatever you're intending to UPDATE first. If you run a simple SELECT...
SELECT myColumn
FROM tbCities08
WHERE Unique_ID = 020001000080
...you will...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 23, 2008 at 8:19 am
Hi mpeters
Here's the theory:
Get the current datetime using getdate()
Strip off the time component, which gives today
Add a day to the result, which gives tomorrow with no time component:
[font="Courier New"]DECLARE...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 23, 2008 at 12:42 am
Now I gotcha, thanks for the extra explanation.
[font="Courier New"]DECLARE @Table TABLE (
[id] bigint IDENTITY PRIMARY KEY CLUSTERED,
lang VARCHAR(100),
code CHAR(1) )
INSERT @Table
SELECT 'en','A' UNION ALL -- 1
SELECT 'en','A' UNION ALL --...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 22, 2008 at 11:58 pm
Thanks for the feedback Robb 🙂
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 22, 2008 at 10:21 am
Hello
Try this out, have a look at the result set (it will contain all the iterations of the dupes) and use it to help explain what you're trying to do.
[font="Courier...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 22, 2008 at 10:19 am
rhagan (9/22/2008)
The same table as the view references contains the field that will determine the what the user can see.
Example:
SELECT t.*
FROM TABLE t
WHERE t.deletedate IS NULL
AND ((IS_MEMBER('role') = 0
...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 22, 2008 at 10:14 am
rhagan (9/22/2008)
The original purpose of this view was to exclude records stamped as delete - deletedate IS NULL.
So these records need to be exlcuded no matter which role the user...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 22, 2008 at 9:53 am
Andrew Gothard (9/22/2008)
From moving over to the new system, NMR = the Identity column for all new values with the Identity column...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 22, 2008 at 9:29 am
Surely this is all you need?
[font="Courier New"]SELECT t.*
FROM TABLE t
WHERE (IS_MEMBER('role') = 0 AND t.deletedate IS NULL) OR IS_MEMBER('role') = 1
--OR ID IN (SELECT ID FROM table WHERE field...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 22, 2008 at 9:28 am
Viewing 15 posts - 9,526 through 9,540 (of 10,143 total)