Forum Replies Created

Viewing 15 posts - 136 through 150 (of 167 total)

  • RE: Converting smalldatetime to lose the minutes

    Or...

    Select Cast(Floor(Cast(GetDate() as float)*24.0)/24.0 as SmallDateTime)

  • RE: Converting smalldatetime to lose the minutes

    Select Stuff(Convert(VarChar,GetDate(),120),15,5,'00:00')

  • RE: How to skip the records

    Easy, but potentially resource and time intensive (for large tables)

    Might as well migrate to a differnt database so you can use the internally...

  • RE: How to skip the records

    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...

  • RE: How to skip the records

    Agreed, but in my case (huge tables) it is REALLY fast.

    One person's sand is another person's sugar!

  • RE: How to skip the records

    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...

  • RE: TSQL Functions

    Try:

    Select Left(@Str,CharIndex(' ',@Str+' ')-1)

  • RE: Case Sensitivity in Selects - Part 1

    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'

     

  • RE: Select any 5 rows in random

    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...

  • RE: DBCC results into tables

    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...

  • RE: DBCC results into tables

    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

  • RE: Need a RELIABLE table-exist test

    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!

  • RE: Need a RELIABLE table-exist test

    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...

  • RE: SP_WHO2

    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...

  • RE: Counting lines of code in all SPs in Database

    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"...

Viewing 15 posts - 136 through 150 (of 167 total)