Viewing 15 posts - 136 through 150 (of 167 total)
Or...
Select Cast(Floor(Cast(GetDate() as float)*24.0)/24.0 as SmallDateTime)
July 14, 2005 at 3:06 pm
Select Stuff(Convert(VarChar,GetDate(),120),15,5,'00:00')
July 14, 2005 at 2:52 pm
Easy, but potentially resource and time intensive (for large tables)
Might as well migrate to a differnt database so you can use the internally...
July 14, 2005 at 2:25 pm
Adding the number column would be a good idea accept for those pesky DELETEs and INSERTs... The numbers would become fragmented and the selection scheme would not function as expected...
July 14, 2005 at 2:09 pm
Agreed, but in my case (huge tables) it is REALLY fast.
One person's sand is another person's sugar!
July 14, 2005 at 1:44 pm
If ya want to play outside of the sandbox
I wrote an Extended Stored Procedure (C/C++ coded DLL) that implements a global Char/VarChar variable store. With...
July 14, 2005 at 1:33 pm
Nice adaptation!
This is the same technique many use with an indexed computed CheckSum() or Binary_CheckSum() column...
... where [Computed ChkSum]=CheckSum(ColName) and ColName='A B C Company'
June 6, 2005 at 8:21 am
You could play this game:
Alter Table [???]
Add GUId as NewId()
...
Select TOP 5 * from [???]
where Binary_CheckSum(GUId)>0
The computed column doesn't really exist (not taking up any disk space) and it changes with...
May 20, 2005 at 3:10 pm
Hello Jeff,
I do this intentionally so I can programatically set the Database when I run the script. If this exact piece of code is used he should set @DB to...
May 12, 2005 at 9:17 am
Along the same idea as previous posts...
Declare @DB VarChar(256)
Set @DB='TempDB'
If Object_Id('TempDB.dbo.#Tmp') is not Null Drop Table #Tmp
Create Table #Tmp
(
FId Int,[FGroup] Int,TotalExtents Int,
UsedExtents Int,FName nVarChar(2000),FPath nVarChar(2000)
)
Insert #Tmp (FId,FGroup,TotalExtents,UsedExtents,FName,FPath)
Exec('Use
May 12, 2005 at 8:19 am
Ya, I did that a lot too, but over the years it became generically easier to use the function as it covers all cases of object qualification.
Good luck!
April 29, 2005 at 8:56 am
Since object names are unique within a database I use a function like this to test for the existance of things:
Create Function ObjectExists
(
@ObjectName VarChar(256)
)
Returns Bit
As Begin
Declare @b-2 Bit
Set...
April 29, 2005 at 8:39 am
If Object_Id('TempDB..#Who') is not Null Drop Table #Who
If Object_Id('TempDB..#DBCC') is not Null Drop Table #DBCC
Create Table #Who
(
SPID1 Int,Status VarChar(64),Login VarChar(64),HostName VarChar(64),
BlkBy VarChar(64),DBName VarChar(64),Command VarChar(64),CPUTime Int,
DiskIO Int,LastBatch VarChar(64),ProgramName...
April 28, 2005 at 11:20 am
Create Procedure OneLine(@p1 int) As Select * from TBL where Col = @p1
How would you count this? As mentioned above, what is the definition of a "line"...
April 28, 2005 at 9:41 am
Viewing 15 posts - 136 through 150 (of 167 total)