You have to concat
the various bits and pieces together yourself and if you only want questions, filter on PostTypeid. The rows with PostTypeid = 1 are the questions.
Putting this in a a query will give you this:
select top 10 -- remove TOP 10 if you want up to 50,000 rows
Title
, Posts.Id [Post Id]
-- add together the bits and pieces to one string
, concat(N'site://questions/', Posts.Id,N'|', Title) as [Question Link]
, concat(N'//stackoverflow.com',N'/questions/', Posts.Id,N'|', Title) as [Raw Question Link]
, DisplayName
, Users.Id [User Id]
, concat(N'site://users/', Users.Id,N'|', DisplayName) as [Author Link]
, concat(N'//stackoverflow.com', N'/users/', Users.Id,N'|', DisplayName) as [Raw Author Link]
from Posts
INNER JOIN Users ON Posts.OwnerUserId = Users.id
where Posts.PostTypeId = 1 -- Questions
Notice that the site name is hardcoded here in the Raw fields. In the Link fields I used the link expansion that works in the Result grid but it won't in CSV output.
Notice the results you will get in Excel:
However, Glorfindel created an expression to translate the database name into an URL so you can output correct URL's directly from the server instead of relying on client-side processing:
LOWER('https://' +
IIF(PATINDEX('%.Mathoverflow%', db_name()) > 0,
IIF(PATINDEX('%.Meta', db_name()) > 0, 'meta.mathoverflow.net', 'mathoverflow.net'),
IIF(PATINDEX('%.Ubuntu%', db_name()) > 0,
IIF(PATINDEX('%.Meta', db_name()) > 0, 'meta.askubuntu.com', 'askubuntu.com'),
IIF(PATINDEX('StackExchange.%', db_name()) > 0,
CASE SUBSTRING(db_name(), 15, 200)
WHEN 'Audio' THEN 'video'
WHEN 'Audio.Meta' THEN 'video.meta'
WHEN 'Beer' THEN 'alcohol'
WHEN 'Beer.Meta' THEN 'alcohol.meta'
WHEN 'CogSci' THEN 'psychology'
WHEN 'CogSci.Meta' THEN 'psychology.meta'
WHEN 'Garage' THEN 'mechanics'
WHEN 'Garage.Meta' THEN 'mechanics.meta'
WHEN 'Health' THEN 'medicalsciences'
WHEN 'Health.Meta' THEN 'medicalsciences.meta'
WHEN 'Moderators' THEN 'communitybuilding'
WHEN 'Moderators.Meta' THEN 'communitybuilding.meta'
WHEN 'Photography' THEN 'photo'
WHEN 'Photography.Meta' THEN 'photo.meta'
WHEN 'Programmers' THEN 'softwareengineering'
WHEN 'Programmers.Meta' THEN 'softwareengineering.meta'
WHEN 'Vegetarian' THEN 'vegetarianism'
WHEN 'Vegetarian.Meta' THEN 'vegetarianism.meta'
WHEN 'Writers' THEN 'writing'
WHEN 'Writers.Meta' THEN 'writing.meta'
ELSE SUBSTRING(db_name(), 15, 200)
END + '.stackexchange.com',
IIF(PATINDEX('StackOverflow.%', db_name()) > 0,
CASE SUBSTRING(db_name(), 15, 200)
WHEN 'Br' THEN 'pt'
WHEN 'Br.Meta' THEN 'pt.meta'
ELSE SUBSTRING(db_name(), 15, 200)
END + '.stackoverflow.com',
IIF(PATINDEX('%.Meta', db_name()) > 0,
'meta.' + SUBSTRING(db_name(), 0, PATINDEX('%.Meta', db_name())) + '.com',
db_name() + '.com'
)
)
)
)
))
It would go as first entry in the concat
statement for the Raw Links. Doing so would also give you this output in a CSV file. I leave that as an exercise for the reader.