« first day (2196 days earlier)      last day (2673 days later) » 

7:10 AM
@TypoCubeᵀᴹ The comment is fine, but why edit the code to add terminators? They're optional after all. If I saw that in the Suggested Edit queue, I would reject it.
 
7:20 AM
I had some comments to move into the answer so I did that against revision 1.
 
7:34 AM
Yay new hat. Shame it will only last a day.
 
 
3 hours later…
10:04 AM
Hello. We have some logic which yields " to which phone should we send the SMS". (In terms of priority). For example me and my wife and my child , we all have phones , but the SMS should be sent only to one person , based on some logic.
It's all working fine. But something bothers me. I see the same calculations appear twice. And I would like to get rid of that.
Any help please?
here is the text version :justpaste.it/127a4
(This is a UDF which should return PhoneID , int).
 
10:39 AM
@RoyiNamir Putting that in a CROSS APPLY should help, I think
Something along the lines of...
SELECT
  ...
FROM
  ...
  CROSS APPLY
  (
    SELECT
      CASE
        WHEN IsPrimary = 1 AND ap.TypeId IN (57, 63) THEN 1
        WHEN ap.TypeId IN (57, 63) THEN 2
        WHEN IsPrimary = 1 THEN 3
      END
  ) AS x (Priority)
WHERE
  ...
  AND x.Priority IS NOT NULL
ORDER BY
  x.Priority  ASC,
  LastUpdated DESC
 
@AndriyM Thank you. I'm checking that solution.
 
I might also consider this variation:
SELECT
  ...
FROM
  ...
  CROSS APPLY
  (
    SELECT
      CASE WHEN ap.TypeId IN (57, 63) THEN 2 ELSE 0 END +
      CASE WHEN IsPrimary = 1         THEN 1 ELSE 0 END
  ) AS x (Priority)
WHERE
  ...
  AND x.Priority <> 0
ORDER BY
  x.Priority  DESC,
  LastUpdated DESC
 
I've used your first solution. thank you :
BEGIN
	DECLARE @parentCustomerID INT

	SELECT @parentCustomerID = c.ParentId
	FROM   Customers AS c
	WHERE  c.CustomerId = @customerid


	DECLARE @phoneId INT = NULL

	SELECT TOP 1 @phoneId = PhoneId
	FROM   App_Phone ap CROSS APPLY (
									SELECT CASE
									    WHEN IsPrimary = 1 AND ap.TypeId IN (57, 63) THEN 1
										WHEN ap.TypeId IN (57, 63) THEN 2
										WHEN IsPrimary = 1 THEN 3
										ELSE 0
										END
								) AS x(Priority)
	WHERE  ap.objTypeId = 1
	       AND ap.objId = @parentCustomerID
@AndriyM If you're here :-) .
Some of my quries doesn't return result for `select.... where column like '%א%'`
Now, column is a an nvarchar column , and still it doesn't return rows.Only when I use like 'N%א%' , t returns rows.
I know that N represents unicode.
But why must I also represent N in n nvarchar column ?
I mean - Nvarchar stores UNICODE data
Where is my mistake ?
 
11:50 AM
Isn't it good practice to have statement terminators? I find code far more readable with terminators.
Although the specific example was rather ok, had good formatting, which is more essential.
And no, I hadn't forgotten. But wanted to do some testing first - in SQL Server - and holidays kicked in.
I have some other work on Windows this week, so I'll be able to update that, too.
 
12:36 PM
@AndriyM Hi Andriy, do you know what is the right method to load data into a fact table? And if you know could you please send a link for any tutorial explains this cause I searched on the internet for hours and what I found only loading data from existent dw projects i.e. from AdventureworkDW to some other projects
I need to transfer data from dimensions to the fact and create the aggregations performed on the fact
 
@RoyiNamir Not really my area of expertise. If presented well, might make a good question on the main, though. I think there was someone among the regular answerers who seemed to know a good deal about string conversion issues.
@Dodi I don't, sorry.
 
@AndriyM Hi and thank you for your answer. You don't need to say sorry and I just assumed you know a bit about BI that' all lol
 
@RoyiNamir see this:
17
Q: Write differences between varchar and nvarchar

Chris LCurrently in our SQL Server 2012 database, we're using varchar, and we'd like to change that nvarchar. I've generated a script to do that. My question is are there any differences in how SQL Server writes to varchar columns vs. nvarchar columns? We have a number of backend procedures that I'm co...

 
Yes It could be a qood question. However, somebody asked the same but I got the explanation in theory rather than practical and this is the issue why I asked
My concerns is if I ask the question I may get down voted !
 
@Dodi or upvoted. depends on how you ask or what your concern is ;)
 
12:49 PM
@TypoCubeᵀᴹ True, but the community do not like the duplicate question!
 
@Dodi have you asked a question?
 
@TypoCubeᵀᴹ I did ask two or three questions on this part of SOF
but didn't get the best answers
 
the 2 I see in your profile are too general. Different to what you asked in here
 
Yes, they were completely different
I am developing a dw and so excited but my progress is going slow with the ETL process specifically in the fact table
All the internet or other textual tutorials are based on predefined data i.e. DW from adventures work
 
So you have a specific problem. Define it - add all the details - and post a question, at the site
 
12:56 PM
I am going to my friend. I may spend sometimes looking for a similar approach
if there is no hope then I will fire a question
 
1:21 PM
@TypoCubeᵀᴹ Yes, many people (including me) regard using statement terminators as best practice). Some people disagree with it. In any case, it is established SE convention not to edit code for what amounts to personal preferences.
 
 
3 hours later…
4:31 PM
How do I make the increment of a primary key increment from one during every update on data. I inserted data to the column CustomerKey and had to delete all the data by chance. Then I tried to populate the data again in the table, but notice Instead of starting from 1, the key start increment from the last record been generated i.e. 275 !
Is there away I can ensure records increment from 1 upwards when I perform the insert for the first time?
 
 
2 hours later…
6:12 PM
6 more hours of hats!
 
6:23 PM
Another day or two for the last hat would have been nice
 
 
2 hours later…
8:31 PM
I ANSWERED A SQL SERVER QUESTION.
Do I get another darth vader hat.
 
8:44 PM
NO
 
8:57 PM
=(
poor me
 
 
1 hour later…
10:20 PM
Holla
 
10:35 PM
@PaulWhite Microsoft's HW actually doesn't suck nearly as bad as their software.
Arc mouse looks cool.
3.5 stars.
That's like a certifiable "Meh" from Amazon. amazon.com/Microsoft-Bluetooth-Surface-Windows-Tablets/dp/…
looks like their trying to do something new though, so kudos to them even if it flops
BTW, my GF just got the new OnePlus 3T
that phone is zomfg nice.
 
 
1 hour later…
11:49 PM
Wait, you have a girlfriend?
She must be like "IT'S ME, EVAN'S GIRLFRIEND"
 

« first day (2196 days earlier)      last day (2673 days later) »