Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 94590

All versions of Microsoft SQL Server (not MySQL). Please also add a version-specific tag, like sql-server-2016, since it is often relevant to the question.

9 votes

Create SQL Randomized Date of Birth

Method 1 select DATEADD(DAY, -(ABS(CHECKSUM(NEWID()) % 36500 )), getdate()); Sample outputs: 1980-11-10 02:19:37.643 1940-08-25 02:20:06.217 1967-10-10 02:20:15.030 2013-03-20 02:20:24.933 1951-11-1 …
DxTx's user avatar
  • 254
2 votes
Accepted

Dynamic dates Pivot

Try this query. I was not able to check the query since I don't have data. If there is an error, please let me know. SELECT DISTINCT BookInventoryDate FROM StartKPA DECLARE @colsValues AS NVARCHAR …
DxTx's user avatar
  • 254
1 vote

How to pivot a table for a set number of combinations?

Try this one... SELECT ID_RECIPE, MAX(CASE WHEN rownumber = 1 THEN component END) AS COMP_1, MAX(CASE WHEN rownumber = 2 THEN component END) AS COMP_2, MAX(CASE WHEN rownumber …
DxTx's user avatar
  • 254