Viewing 15 posts - 1,396 through 1,410 (of 1,416 total)
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
Ryan Randall's solution:
select cast('1 ' + 'February, 2004' as datetime)
August 10, 2006 at 9:27 am
On quickly looking at this, there is no join condition between ASP_MASTER and the other tables. This will produce a cartesian product; not at good idea!
You could probably optimise this...
August 10, 2006 at 4:11 am
If possible, try and get at least two example dates and values. Maybe 2006-08-09 = 732503 and 2006-08-08 = 732502
You should then be able to work out if it is a...
August 9, 2006 at 8:26 am
I have used application locks for this sort of proc. The idea is similar to using a table except everything is in memory. The outline code is:
-- start of proc
exec...
August 8, 2006 at 3:10 am
Opps...
select ceiling(sum(datediff(minute, tStartTime, tEndTime))/60.0)
from ( select case when tStartTime < @reportStart
then @reportStart
else tStartTime
end as tStartTime
,case when (tEndTime > @reportEnd OR tEndTime IS NULL) --!!!!!
then @reportEnd
else tEndTime
end as tEndTime
from @t
where tEndTime >...
July 26, 2006 at 10:50 am
Answered recently:
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=296735
July 26, 2006 at 10:08 am
or something like:
declare @t table
(
nPK int not null
,nJobID int not null
,tStartTime datetime not null
,tEndTime datetime null
,lJobOpen bit not null -- is the needed if tEndTime is null?
)
insert @t
select 1, 1,...
July 26, 2006 at 10:00 am
When calling the function does explicit casting work?
eg Instead of t1.seatloc_seat + 1 try cast(cast(t1.seatloc_seat as int) + 1 as nvarchar(50))
July 21, 2006 at 6:18 am
create trigger dbo.Assets_tiu
on dbo.Assets
after insert, update
as
set nocount on
-- Assuming table has PK of AssetID
update dbo.Assets
set LastUpdated = getdate()
where dbo.Assets.AssetID in (select I.AssetID from inserted I)
go
July 20, 2006 at 4:22 am
Sorry Ryan,
I did not really read the thread and had done something similar with a bitwise date format last week.
Your solution is very elegant.
July 11, 2006 at 7:00 am
Try using a function like:
create function dbo.SillyDate2SQLDate
(
@SillyDate varchar(15)
)
returns datetime
as
begin
declare @RetDate datetime
declare @Months table
(
MonthNbr char(2) collate database_default not null
,SearchMonth varchar(9) collate database_default not null primary key
 
July 11, 2006 at 6:16 am
Viewing 15 posts - 1,396 through 1,410 (of 1,416 total)