Viewing 15 posts - 3,031 through 3,045 (of 3,396 total)
Are you using AdventureWorks as your model? Or if not, please post T-SQL to create tables and add some sample data and expected results. Apologies if I'm slow,...
March 1, 2014 at 5:26 pm
join to a table-valued function using CROSS APPLY?
February 25, 2014 at 8:12 pm
Sounds like you're doing what i used to do - summarizing unnormalized healthcare/oncology data. If you can either normalize your underlying tables or create a stored procedure or view...
February 23, 2014 at 1:13 pm
Google is your friend.
If you're looking for something like interview answers, an interview like that will eat you alive unless you know the stuff cold. Any DBA worth his...
February 22, 2014 at 8:29 pm
SELECTDate_Month
, LEFT(Date_Month,3) AS Mo3
, CAST(RIGHT(Date_Month,4) AS INT) AS Yr
, CAST(LEFT(Date_Month,3) + ' 1, ' + RIGHT(Date_Month,4) AS DATE) AS DateFun
FROM (
SELECT 'APR 2012' AS Date_Month
UNION ALL
SELECT 'JAN 2012'
UNION...
February 22, 2014 at 1:55 pm
Two options:
Create another query based on the summary query and the original table. include the column from the original table that you couldn't use in the summary query.
Or
Build...
February 21, 2014 at 4:02 pm
Maybe something like this?
SELECT fileName
, RecID
, page_follow
, rn
, PrevID
, RecID-PrevID AS GapSize
FROM
(SELECT [file_name] AS fileName
, [id] AS RecID
, page_follow
, ROW_NUMBER() OVER (ORDER BY [id]) AS rn
, MAX([id]) OVER (PARTITION BY...
February 21, 2014 at 7:46 am
Good thing, because I was just starting to think about it and try to figure out a solution (Good learning exercise, but if you have actual work to do, not...
February 20, 2014 at 10:14 pm
Probably the easiest way would be to use a query of one of the system tables and see if you can match that way...
use MyDb;
go
DECLARE @TableName VARCHAR(25);
SET @TableName = 'Hospital';
Select...
February 20, 2014 at 8:47 pm
Is this close? Note, as Craig mentioned, you need a Tally table to do this.
Here's his code for creating one:
http://www.sqlservercentral.com/scripts/Advanced+SQL/62486/
use TEMPDB;
go
DROP TABLE #Parts;
GO
CREATE TABLE #Parts (
RecKey INT,
Part CHAR(2),
LT INT,
StartDate...
February 19, 2014 at 5:09 pm
Yep, makes it MUCH easier to see what you were doing wrong. Way to go, young Jedi.
February 7, 2014 at 5:08 pm
You could do it inside a stored procedure, and then grant the right to execute said stored procedure to whoever you wanted. You could add EXECUTE AS <user> inside...
February 6, 2014 at 9:58 pm
The problem is that you left out the other INNER JOIN statements:
...
FROM
vt_animals as A
INNER JOIN
vt_exam_headers as EH...
February 6, 2014 at 7:29 pm
Viewing 15 posts - 3,031 through 3,045 (of 3,396 total)