Viewing 15 posts - 136 through 150 (of 188 total)
The two I keep on my desk, and are full of sticky notes because they are so good:
Henderson's Guru book mentioned above
O'Reilly Transact-SQL Programming
June 22, 2004 at 9:33 am
select a.*, b.itemnum, b.itemdesc from #t a, #t b
where a.person = b.person
and a.itemnum > b.itemnum
order by 1,2,4
person itemnum itemdesc itemnum itemdesc
----------------------------------------------------------------------
Jim 123099 Folding Chairs 123044 Gas Trimmer
Jim 123105 Elite Vacuum 123044 Gas Trimmer
Jim 123105 Elite Vacuum 123099 Folding Chairs
Jim 194122 Shop-Sweep Indoor/Outdoor Vac 123044 Gas Trimmer
Jim 194122 Shop-Sweep Indoor/Outdoor Vac 123099 Folding...
June 21, 2004 at 8:59 pm
Look up "date formats" in BOL. You can get all the pre-fab constants in a ref titled, "CAST AND COVERT" in the T_SQL library.
If you a dumping your extract from...
June 17, 2004 at 3:40 pm
Push from SQL Server to your ascii extract with this:
select convert(varchar(25), getdate(), 113)
My instance of Oracle reads this as a date without using any to_char or to_date functions.
Be sure to...
June 17, 2004 at 3:28 pm
You can tell Oracle to recognize pretty much any format. How you do it depends on whether you actually have a date data type or a varchar display of a...
June 17, 2004 at 2:07 pm
BTW, don't understand why you would select into with an order by?
June 17, 2004 at 10:10 am
select
1 c1,
2 c2,
3 c3,
4 c4,
5 c5,
6 c6
into #emp_temp
declare @sql nvarchar(1000), @col_name varchar(10), @orderby varchar(10)
set @col_name = 'c1' --this has to be one of the column names
set @orderby = 'desc'
set @sql...
June 17, 2004 at 10:08 am
Simple and elegant.
I am at a loss to understand why we inherit such tables in the first place?! Primary Keys, Unique Constraints... these seem to be foreign concepts to some.
June 4, 2004 at 2:11 pm
I don't like to waste an unnecessary function call when I use this so often I don't forget anyway:
SELECT CAST(CONVERT(VARCHAR(15),GETDATE(),101) AS DATETIME)AS "TruncAndCastDateTime"
GO
SELECT CAST(CONVERT(VARCHAR(15),GETDATE(),101) AS SMALLDATETIME)AS "TruncAndCastSmallDateTime"
GO
By the way, smalldatetime is half...
June 4, 2004 at 9:55 am
I keep this terrific article Chris wrote in my virtual briefcase:
http://www.sqlservercentral.com/columnists/ccubley/findinganddeletingduplicatedata.asp
June 4, 2004 at 9:42 am
"There is a limitation in the Excel driver that effects the 'DELETE' keyword. If you attempt to use it, you will receive the error message, "Deleting data in a linked...
May 5, 2004 at 10:04 am
Let the point be that a trigger may be your answer. You can play with the logic yourself until it meets yours needs. Maybe like this?
SELECT startdt, enddt, jobnum
FROM dbo.jobschedule
startdt enddt jobnum
04/01/2004 04/02/2004 1
04/01/2004 04/02/2004 2
04/01/2004 04/02/2004 3
alter...
April 28, 2004 at 12:56 pm
SELECT *
FROM dbo.TableA
iID sState dDate
1 InProgress 02/04/2004
1 Resolved 02/04/2004
1 Awaiting Feedback 06/04/2004
1 InProgress 03/04/2004
2 InProgress 02/04/2004
2 Resolved 02/04/2004
2 Awaiting Feedback 06/04/2004
2 InProgress 03/04/2004
select
iID, sState, min(dDate) MinDate
from tablea b
group by
iID, sState
having
sState = 'InProgress'
iID sState MinDate
1 InProgress 02/04/2004
2 InProgress 02/04/2004
If that's not what you want, show me the result set you expect based on the table...
April 28, 2004 at 12:33 pm
SELECT startdt, enddt, jobnum
FROM dbo.jobschedule
startdt enddt jobnum
04/01/2004 04/02/2004 1
04/01/2004 04/02/2004 2
04/01/2004 04/02/2004 3
CREATE TRIGGER jobscheduletrigger
ON jobschedule
for insert
AS
declare @icount as integer
set @icount =
(select count (*)
from inserted i
inner join jobschedule j
on j.startdt = i.startdt
and j.enddt = i.enddt)
if @icount...
April 28, 2004 at 11:13 am
select * from #temp order by 1
1 4/5/2004 inprogress
1 4/6/2004 inprogress
1 4/4/2004 inprogress
2 4/4/2004 inprogress
3 4/5/2004 inprogress
select
count(distinct intid) countdistinctid,
datepart(month, progdate) currmonth
from
#temp
where
state = 'inprogress'
group by datepart(month, progdate)
3 4
April 28, 2004 at 10:32 am
Viewing 15 posts - 136 through 150 (of 188 total)