Forum Replies Created

Viewing 15 posts - 271 through 285 (of 337 total)

  • RE: random records

    Use Top clause without order by clause.

    Select top 10 columnname from yourtable.

  • RE: how to use convert for an alias name of column in case statement

    Not sure but try this

    CAST(CASE

    WHEN sp.[SalesPersonID] IS NULL THEN 0

    ELSE 1

    END AS BIT)AS [SalesPersonFlag]

  • RE: group by - max (position) ??

    Are you sure you are getting the same value of Getdate() for each record ?

    CREATE TABLE [dbo].[mfRepositoryErrors]

    (

    [errid] [int] NOT NULL,

    [errorCode] [varchar](10) NOT NULL,

    [description] [text] NULL,

    [severity] [varchar](25) NULL,

    [occurred] [datetime] NULL,

    )

    Insert into...

  • RE: Delete duplicate records in a table

    Jeff Moden (12/4/2010)


    Sachin Nandanwar (12/3/2010)


    Also it is a better idea to put the recover model to SIMPLE or else your log file will bloat.But make sure you take a Full...

  • RE: Delete duplicate records in a table

    Also it is a better idea to put the recover model to SIMPLE or else your log file will bloat.But make sure you take a Full and a T log...

  • RE: Using CASE in a WHERE clause

    Cant you just use IF blocks ?

  • RE: Split string of concatenated words

    My attempt at this one.

    declare @v-2 varchar(50)='StartDateEarlierThanCurrentDate'

    declare @splitvalues varchar(50)=''

    ;with cte

    as

    (

    select row_number()over(order by (select 1))id,SUBSTRING(@v,number,1)num,number from master..spt_values

    where type='p' and number between 1 and LEN(@v)and SUBSTRING(@v,number,1)=UPPER(SUBSTRING(@v,number,1))

    collate Latin1_General_CS_AS_WS

    )

    select @splitvalues=@splitvalues + ' ' +...

  • RE: Returning multiple fields to select from inline table function

    Something like this

    select * from dbo.function1

    Cross Apply dbo.function2

  • RE: XQuery

    But what is the basis for your update?You want to update name to "C" wherever id=2 exists?

  • RE: MONTH in the form on Jan, Feb, ....

    pramod_yg (11/24/2010)


    Thanks Sachin. This one is totally new to me 🙂

    You are welcome:-).Just incase you need to get weekday names you can replace month with weekday.

    select DATENAME(WEEKDAY,GETDATE())

  • RE: MONTH in the form on Jan, Feb, ....

    pramod_yg (11/23/2010)


    Dear All,

    I have a query. Is there any function what returns me the char value of month. i mean, i want Jan instead of 1. when i use Month(getdate())...

  • RE: Replacing only numeric value on a string

    luissantos (11/23/2010)


    Hello Sachin and Asparna

    the script of Sachin is quiet perfect , but the unique problem is the result :

    my invoice number 4562

    i dont need the last number "2" of...

  • RE: how to get consecutive records grouped

    Eralper (11/22/2010)


    Hello,

    I guess what your are looking for is t-sql dense_rank() function

    select

    dense_rank() over (order by cat),

    ...

  • RE: how to get consecutive records grouped

    It's quite difficult to give a solution without actually looking at the records which are causing the problem.

    My wild guess would be use a dense_rank instead of row_number.

    select

    ...

  • RE: Replacing only numeric value on a string

    declare @str varchar(50)='my invoice number 3688992'

    declare @num varchar(max)=''

    declare @value varchar(50)='456'

    select @str

    select @num=@num+''+n from

    (

    select SUBSTRING(@str,number,1)n from master..spt_values

    where number<LEN(@str)and type='P'

    )T where n between '0' and '9'

    select REPLACE(@str,@num,@value)

Viewing 15 posts - 271 through 285 (of 337 total)