Viewing 15 posts - 5,701 through 5,715 (of 10,144 total)
sqlnaive (9/7/2012)
For such kind of reasons we should avoid float and real datatypes ? And rather use decimal and numeric ?
Have a look in BOL under CONVERT to see which...
September 7, 2012 at 5:50 am
sqlnaive (9/7/2012)
Check itdeclare @test-2 float
select @test-2 = 0.1234123412341234
select @test-2
select ltrim(rtrim(@test))
Results are as follows:
0.123412341234123
0.123412
RTRIM and LTRIM both take a varchar parameter. The float value is implicitly converted to a varchar, then...
September 7, 2012 at 5:35 am
Like this?
select
DatePart(hour,Reading_Date) as [hour],
t.Tank_Product ,
convert(Date,Reading_Date,103) as [date],
sum(tr.Sales) as sales,
sum(tr.Price)as price ,
sum(tr.Amount)as amount
INTO #Results
from dbo.Tanks as t
inner join Transactions as tr
on t.Simmons_PanelID = @panelid
and...
September 7, 2012 at 5:19 am
SELECT
TimeVC,
FirstColonPosition = CHARINDEX(':',TimeVC,1),
[Hours] = LEFT(TimeVC,CHARINDEX(':',TimeVC,1)-1)
FROM (
SELECT TimeVC = '73:59:59' UNION ALL
SELECT '144:44:59') d
September 7, 2012 at 4:11 am
Usman Butt (9/7/2012)
ASFSDJG (9/7/2012)
If we force clustered index it is display all the columns .
select * from <table_name> with (index (cluster index name>)) where field_id = 2
its gets result.
Execution plan...
September 7, 2012 at 3:30 am
Looks fine to me, Tom. It's important that you don't have dupes in the matrix table source (the CROSS JOIN bit), if the two columns returned are the PK's of...
September 7, 2012 at 2:38 am
bmahf (9/6/2012)
September 7, 2012 at 2:11 am
ScottPletcher (9/6/2012)
bmahf (9/6/2012)
September 7, 2012 at 2:09 am
Phil Parkin (9/6/2012)
Ah yes, thanks guys.Note to self: read more carefully next time 🙂
Heh at least your code works, Phil - even if it doesn't quite match the spec. Mine...
September 6, 2012 at 8:52 am
ChrisM@Work (9/6/2012)
One more:
TimeResult3= CAST(
DATEADD(ns,ABS(DATEPART(ns,btime)-DATEPART(ns,atime)),
DATEADD(ss,ABS(DATEDIFF(ss, aTime, btime)),CAST('1900-01-01 00:00' AS datetime2)))
AS TIME(7))
Aarrgghh!! They all fall over given suitable edge cases in the data.
DATEDIFF counts boundaries -...
September 6, 2012 at 8:50 am
Phil Parkin (9/6/2012)
mssqlsrv (9/6/2012)
I think you can not use variable in order by clause.Variables are only allowed when ordering by an expression referencing a column name.
Yeah you can. Just tried...
September 6, 2012 at 8:43 am
Something like this:
SELECT
SubTotalSplit = CASE WHEN OrdMain.SubTotal = 0.01 THEN '= 0.01' ELSE '<> 0.01' END,
sumx = ( (SUM(CASE (LEFT(RIGHT(Rtrim(summary), 12), 5))
WHEN 'EURO/' THEN OrdItem.PriceEach * OrdItem.Quan...
September 6, 2012 at 5:40 am
One more:
TimeResult3= CAST(
DATEADD(ns,ABS(DATEPART(ns,btime)-DATEPART(ns,atime)),
DATEADD(ss,ABS(DATEDIFF(ss, aTime, btime)),CAST('1900-01-01 00:00' AS datetime2)))
AS TIME(7))
September 6, 2012 at 4:53 am
Nice one, Paul.
Here are two different one-line TSQL solutions:
;With MyCTE (aTime, bTime)
AS
(
SELECT CONVERT(datetime2,'1900-01-01 00:08:00.0000001'), CONVERT(datetime2,'1900-01-01 00:09:18.361')
UNION ALL SELECT '1900-01-01 00:08:00.0000001', '1900-01-01 00:13:50.705'
UNION ALL SELECT '1900-01-01 00:09:18.361', '1900-01-01 03:13:50.7050001'
UNION ALL...
September 6, 2012 at 4:05 am
Try declaring @index as int. From BOL: "A sort column can be specified as a name or column alias, or a nonnegative integer representing the position of the name or...
September 6, 2012 at 3:20 am
Viewing 15 posts - 5,701 through 5,715 (of 10,144 total)