Viewing 15 posts - 3,001 through 3,015 (of 4,087 total)
sgmunson (7/8/2015)
DECLARE @ProdCodes AS TABLE (
Prefix varchar(8),
Code varchar(5)
);
INSERT INTO @ProdCodes (Prefix, Code)
VALUES
('b', 'CH0'),
('b', 'CH1'),
('b', 'CH2'),
('b', 'CHX'),
('b', 'CM0'),
('b', 'CM1'),
('b', 'CM2'),
('b', 'CMX'),
('b', 'CN0'),
('b', 'CN1'),
('b', 'CN2'),
('b', 'CMX');
WITH CTE AS (
SELECT Prefix, Code,
CASE SUBSTRING...
July 8, 2015 at 1:31 pm
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...
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,...
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
July 2, 2015 at 2:16 pm
Phil Parkin (7/2/2015)
drew.allen (7/2/2015)
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...
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...
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...
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,...
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...
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
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...
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...
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...
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...
June 19, 2015 at 11:33 am
Viewing 15 posts - 3,001 through 3,015 (of 4,087 total)