Viewing 15 posts - 3,001 through 3,015 (of 4,085 total)
All SQL code is transactional. If you aren't specifically declaring transactions, you are most likely using autocommit where every statement is its own transaction. The ROLLBACK will only...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
July 7, 2015 at 3:22 pm
You were actually very close. The problem is here.
order by ABS (DateAdd(Minute, 30 * (DateDiff(Minute, 0, closedate) / 30), 0)) ASC
DATEADD() returns a date/time and ABS() takes a float,...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
July 6, 2015 at 8:06 am
Cursors generally perform horribly. If you give us more details about what you're trying to accomplish, we might be able to help you rewrite it without cursors.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
July 2, 2015 at 2:16 pm
Phil Parkin (7/2/2015)
drew.allen (7/2/2015)
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
July 2, 2015 at 8:36 am
If you don't specify the ROWS or RANGE, it uses RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, so the current row is always the max value in that range with...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
July 2, 2015 at 7:08 am
I think a much better approach is to update your Access report. It's been awhile, but there should be settings in your Access report to set minimum and maximum...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
June 29, 2015 at 10:03 am
You can actually do this without CURSORs or temp tables.
DECLARE @sqlText nvarchar(1000)
SELECT @sqlText = 'SELECT c.ColumnName, MIN(dt) AS EarliestDate, MAX(dt) AS MostRecentDate FROM eddsdbo.Document CROSS APPLY ('
+ STUFF((
SELECT 'UNION SELECT...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
June 29, 2015 at 7:58 am
You definitely don't need a cursor. Using the following setup:
DECLARE @StoreHours TABLE
(
store_id int,
MonOpen varchar(10),
MonClose varchar(10),
TueOpen varchar(10),
TueClose varchar(10),
WedOpen varchar(10),
WedClose varchar(10),
ThuOpen varchar(10),
ThuClose varchar(10),
FriOpen varchar(10),
FriClose varchar(10),
SatOpen varchar(10),
SatClose varchar(10),
SunOpen varchar(10),
SunClose varchar(10)
)
insert @StoreHours
select 1,...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
June 26, 2015 at 2:09 pm
Unless all of your columns are the same datatype, this is a VERY BAD IDEA. In order for this to work, all of your columns in your rows would...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
June 24, 2015 at 7:42 am
If I understand what you are asking, try the following.
SELECT *
FROM your_table
ORDER BY CASE WHEN <your criteria here> THEN your_date_field ELSE '9999-12-31' END ASC
, your_date_field DESC
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
June 22, 2015 at 3:42 pm
If I understand what you're trying to calculate, your data is incomplete. If you want to plan a route on a 2-dimensional surface, e.g. a plane or the surface...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
June 22, 2015 at 11:52 am
RonKyle (6/22/2015)
I didn't see anywhere example of sequence object in composite PK
The sequence by its nature would not need to be part of a composite key. It will be...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
June 22, 2015 at 9:55 am
ScottPletcher (6/19/2015)
drew.allen (6/19/2015)
By default, SQL Server joins tables in left-to-right order,
I'm not sure it's safe to make that blanket statement. I think SQL will join in whatever order it...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
June 19, 2015 at 3:23 pm
By default, SQL Server joins tables in left-to-right order, but you can override that behavior by using parentheses in your JOIN clause.
SELECT
artefacts.name AS DB, *
FROM
@artefacts artefacts
LEFT OUTER JOIN (
@relationships relationships
INNER...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
June 19, 2015 at 11:33 am
I realized late yesterday that my query needed some updates. With the sample data that was posted, I was able to update the script and get something that worked.
;
WITH...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
June 19, 2015 at 10:13 am
Viewing 15 posts - 3,001 through 3,015 (of 4,085 total)