Forum Replies Created

Viewing 15 posts - 76 through 90 (of 167 total)

  • RE: How to output columns in addition to the GROUP BY column

    You can also "see" the non-grouped columns within a given group if you can specifically select for them with a known column value within an aggregate operator. So, if each...

  • RE: Add incremental count to group of rows

    And yet again using Select ... Into ...

    if object_Id('tempdb.dbo.#t1') is not null drop table dbo.#t1

    if object_Id('tempdb.dbo.#t2') is not null drop table dbo.#t2

    select 'Smith'[LName],'Randy'[FName] into dbo.#t1

    union all select 'Smith','John'

    union all select...

  • RE: Add incremental count to group of rows

    Ya, I agree, the order of the data is important. It generally works for my jobs as the natural order of the data is correct for this process. However, you...

  • RE: Add incremental count to group of rows

    Nobody mentioned that you could use UPDATE. Add in integer column and try this:

    Declare @PrevGroupingColumn VarChar(256),@i Int

    Select @PrevGroupingColumn='' -- Any value that would not occur in the grouping column.

    Update dbo.YourTable...

  • RE: Bypass transaction log with DELETE

    ... and sometimes its just better to SELECT ... INTO ... the stuff you want to keep and then rebuild indices and other stuff afterwards on that smaller dataset. Just...

  • RE: finding non alphanumeric characters

    Try this...

    Select * from dbo.YourTable

    where SomeCol like '%[^ -~]%' collate Latin1_General_BIN

    the key here is to specify a binary collation type so that the like-mask works as you would expect.

    the like...

  • RE: Database name with special character(Urgent)

    Have we learned nothing from the dark ages of "religious" intolerance...

  • RE: PATINDEX bug?

    You need to specify a collation that distinguishes between upper and lower case, such as...

    declare @Pattern varchar(250)

    set @Pattern = '%['+char(190)+'-'+char(192)+']%'

    SELECT PATINDEX (@Pattern collate Latin1_General_BIN,'abcdefghijk')

     

  • RE: UNION IF query problem

    You could select each query into a temp table or temp variable saving each @@RowCount then if both row counts are not zero select both tables with Union All...

  • RE: sort order

    I would sort the data locally at the app. That way the user could change his mind after the initial fetch of the data and could have it re-sorted WITHOUT...

  • RE: Eliminating Leading Char Zeros

    In light of the unanswered "edge" conditions how about this?

    Use TempDB

    If Object_Id('dbo.test') is not Null Drop table dbo.Test

    Select '123'[CharNum] into dbo.Test

    Union All Select '0123'

    Union All Select '000123'

    Union All Select '000'

    Union...

  • RE: Get domain

    Try this:

    Declare @i Int,@Domain VarChar(256)

    Select

       @i=CharIndex('\',suser_sname()),

       @i=Case @i when 0 then 0 else @i-1 End,

       @Domain=Left(suser_sname(),@i)

    Print @Domain

  • RE: Eliminate top and bottom percent of records

    Hmmm, forgot to adjust the code for the variables...

    *If* you could add an Identity column to your data when you import it (ordered properly), you could:

    Declare @Lo Int,@Hi Int

    Select...

  • RE: Eliminate top and bottom percent of records

    *If* you could add an Identity column to your data when you import it (ordered properly), you could:

    Declare @Lo Int,@Hi Int

    Select @Lo=Ident_Current('dbo.Data')*0.10,@Hi=Ident_Current('dbo.Data')-@Lo

    Select * from dbo.Data where Ident between Ident_Current('dbo.Data')*0.10...

  • RE: Compress backup files

    If your shop permits controlled use of xp_CmdShell I would use WinZIPs (v9 or greater) command-line module. With it you can compress (multiple levels) and encrypt (multiple techniques) your backup files simultaneously....

Viewing 15 posts - 76 through 90 (of 167 total)