Forum Replies Created

Viewing 15 posts - 31 through 45 (of 52 total)

  • RE: Retrieve comma-separated list within group by

    Hi Lynn & Jeff,

    I made a mistake there is no traingular join. I don't quite remember why i mentioned it, I guess I was thinking about not...

  • RE: Substring?

    Hi,

    If ':Entity' is common among all the values then

    select left(columnname,len(substring(columnname,1,charindex(':',extra)-1))) from tablename

    please try this

    create table #chk(colm varchar(30))

    insert into #chk

    select 'pp_uniline_usd:Entity' union all

    select 'dfsdafsdfsdaf:Entity' union all

    select...

  • RE: Selecting 2nd or 3rd Duplicate in a recordset

    Hi,

    Is this what you need?

    create table #BuildingJob(Bldg int,Job varchar(50))

    insert into #BuildingJob

    select 100, 'Plumber' UNION ALL

    select 202, 'Plumber' UNION ALL

    select 301, 'Plumber' UNION ALL

    select 521, 'Security' UNION ALL

    select 523, 'Security'...

  • RE: Need to count the number of orders placed in one year.

    Hi there,

    I have tried to solve your problem using row_number() and pivot function.

    create table #tblItems(ItemName char(1),Date datetime)

    insert into #tblItems

    select 'a','2008-01-01 00:00:00.000' UNION ALL

    select 'a','2008-01-01 00:00:00.000' UNION ALL

    select 'b','2008-01-01...

  • RE: Retrieve comma-separated list within group by

    Hi,

    I think I got it right by changing the query.

    select IssueNoteID,StockCategoryID,QtyIssued,Left(GRNNo,len(GRNNo)-1)

    from (

    Select IssueNoteID,StockCategoryID,Sum(IssuedItemQty) as QtyIssued,( SELECT G.GRNNo + ','

    ...

  • RE: Two primary key in a table

    Hi Adi,

    Thanks for correction I wasn't sure about clustered index on primary keys though.

    May be you can point what anomalies could arise if however...

  • RE: Two primary key in a table

    hi there,

    I would love to know why do you need two primary keys in your table.

    Although i think in relational database a primary key...

  • RE: average rows between last match

    Hi there,

    I think you should try this and tell me if I have understood your problem right. I would appreciate a response

    create table #tblItem( dt datetime, ItemID int)

    insert into...

  • RE: Week numbers and week start dates

    Hi there,

    I have tried to write a query for your problem with this sample table, tblPurchaseOrder - PurchaseOrderDate & GrandTotal

    here it is-

    select weekno,newdate,sum(grandtotal) as grandtotal...

  • RE: All rows except the first rows should be printed.

    Hi,

    you might try this-

    select ...(your query goes here)

    except

    select top 1 ..(your query goes here)

  • RE: HOW TO CONVERT CSV STRING INTO SQL SERVER 2008 TABLE USING XML

    Hi Shantaram,

    The given code logic i had posted earlier would work well for characters strings as well, if it is written in comma separated list.

    As per the given code:

    "

    declare...

  • RE: HOW TO CONVERT CSV STRING INTO SQL SERVER 2008 TABLE USING XML

    Hi Shantaram,

    The given code logic i had posted earlier would work well for characters strings as well, if it is written in comma separated list.

    As per the given code:

    "

    declare...

  • RE: HOW TO CONVERT CSV STRING INTO SQL SERVER 2008 TABLE USING XML

    Hi shantaram,

    You can use Tally table method as described in "Numbers or Tally Table"

    article by Jeff Gordan on this site.There might also be other solutions by using loop.But for starters...

  • RE: String Operation in Stored Procedure

    Hi there,

    you can use replace function which has following syntax

    -: replace(@stringvar,charactertoreplace,newcharacter)

    for e.g.

    DECLARE @HashText nvarchar(10)

    set @HashText= '''1,2,3,4'''

    declare @grate nvarchar(10)

    set @grate=replace(@HashText,'''','')

    select @grate

  • RE: How can we calculate Age of employee?

    Hi,

    you can try this

    select EMP_CODE,DATE_OF_BIRTH ,DATEDIFF(DD,DATE_OF_BIRTH,getdate())/365 as years,(DATEDIFF(DD,DATE_OF_BIRTH,getdate())%365)/30 as months,

    DATEDIFF(DD,DATE_OF_BIRTH,getdate())%365%30 as days

    from EMP_MST where accountid=4

    Hitendra

Viewing 15 posts - 31 through 45 (of 52 total)