Viewing 15 posts - 1,456 through 1,470 (of 1,489 total)
This is more efficient:
select T.tDate as DateFrom
,isnull
(
(select min(tdate)
from @t T1
where T1.price <> T.price
and T1.tdate > T.tdate) - 1
, D.MaxTDate) as DateTo
,T.price
from @t T cross join
(
select min(T5.tdate),...
August 23, 2006 at 3:11 am
Try something like:
select *
from dbo.Companies C
join dbo.Contacts E on C.companyId = E.companyId
where E.contactId = ( select min(E1.contactId)
from dbo.Contacts E1
where E1.companyID = C.companyID)
August 22, 2006 at 12:26 pm
There is probably a better way, but this seems to work.
declare @t table
(
tDate datetime not null primary key
,price int not null
)
insert @t
select '20070101', 100 union all
select '20070102', 100 union all
select...
August 22, 2006 at 11:38 am
try:
INSERT INTO my_table (comments,
sr_status,
sr_notes_count,
sr_activity_count,
last_updated_dt)
SELECT 'some input comments',
(SELECT max(status) FROM my_table_2 WHERE id = 123),
(SELECT count(*) FROM my_table_3 WHERE id = 123),
(SELECT count(*) FROM...
August 18, 2006 at 11:25 am
PW's approach is more efficient.
--test data
declare @t table
(
tName varchar(20) not null
,Event varchar(20) not null
,tTime datetime not null
)
-- 7.34% of cost
insert @t
select 'Name1', 'Start', convert(datetime, '8/16/06 8:00 AM', 0) union all
select...
August 18, 2006 at 10:57 am
--test data
declare @t table
(
tName varchar(20) not null
,Event varchar(20) not null
,tTime datetime not null)
insert @t
select 'Name1', 'Start', convert(datetime, '8/16/06 8:00 AM', 0) union all
select 'Name2', 'Start', convert(datetime, '8/16/06 8:15 AM', 0)...
August 18, 2006 at 10:33 am
Run the profiler on the bits of the application which do not work and see what is called just before they fail.
August 18, 2006 at 3:38 am
Your query looks like it should work. You could simplfy it by trying something like:
SELECT A.t_Code
FROM C_CODES A
LEFT JOIN Stories S ON S.story_dt BETWEEN '20060810 09:00' AND '20060810 10:00'
AND ' '...
August 18, 2006 at 3:15 am
Try:
alter database abcd
set recovery simple
use abcd
go
dbcc shrinkfile(abcd_log, 200)
-- if originally in full recovery, reset
alter database abcd
set recovery full
You will need to do a full backup afterwards.
August 17, 2006 at 8:44 am
Be careful with nulls but try something like:
select *
from dbo.Employees E
where not exists (select *
from dbo.ModuleLog L
where L.EmployeeName = E.EmployeeName
and L.DOB = E.DOB)
or
select E.*
from dbo.Employees E
left join dbo.ModuleLog L on...
August 14, 2006 at 9:39 am
I have never called an Oracle SP from T-SQL but you could try passing @status as an output parameter.
eg exec DEV..SYSADM.update_procedure @Username,@status OUTPUT
August 14, 2006 at 8:18 am
No problems - I know the feeling.
At the time I thought Erland Sommarskog's post succinctly summed up the issues. I just re-posted it as I have found it to be...
August 14, 2006 at 5:24 am
The original question was about identities so I answered it.
I agree that you have to think very carefully before using identity as a Primary Key but quite often one has...
August 14, 2006 at 3:46 am
declare @t table(namestr varchar(50) not null)
insert @t
select 'Aardvark, Archie (1)' union all
select 'Baboon, Bob (2)' union all
select 'Chimp, Charlie (3)'
select ltrim(rtrim(left(namestr, commaPos - 1))) as LastName
,ltrim(rtrim(substring(namestr, commaPos + 1, bracket1Pos...
August 10, 2006 at 11:06 am
Use SCOPE_IDENTITY() after each insert. Something like:
declare @LastID int
insert table1(...) select ...
set @LastID = SCOPE_IDENTITY()
insert table2(Table1ID, ...) select @LastID, ...
set @LastID = SCOPE_IDENTITY()
insert table3(Table2ID, ...) select @LastID, ...
August 10, 2006 at 9:33 am
Viewing 15 posts - 1,456 through 1,470 (of 1,489 total)