Forum Replies Created

Viewing 15 posts - 16 through 30 (of 81 total)

  • RE: Return most occuring records

    I hope you are looking for this query

    SELECT TOP 100 WITH TIES NameField

    FROM table

    GROUP BY NameField

    ORDER BY COUNT(NameField) DESC

     

  • RE: SELECT query - group by and concatenate

    Hope this helps

    DECLARE @tbl TABLE

     (RowId  VARCHAR(20),

     RValue  VARCHAR(30),

     Lineage  VARCHAR(3000) DEFAULT '',

     Depth  INT)

     

    insert into @tbl(RowId,RValue)  values('WV', 'Kanawha')

    insert into @tbl(RowId,RValue)  values('WV', 'Putnam')

    insert into @tbl(RowId,RValue)  values('WV', 'Dodridge')

    insert into @tbl(RowId,RValue)  values('WV', 'Rhone')

    insert into @tbl(RowId,RValue)  values('OH',...

  • RE: Substring with a variable first position

    Also you could try this.

     

     SELECT PARSENAME('9.200.12.13', 3) AS 'SecondOctet' UNION ALL

     SELECT PARSENAME('11.200.12.13', 3) AS 'SecondOctet' UNION ALL

     SELECT PARSENAME('120.200.12.13', 3) AS 'SecondOctet' UNION ALL

     SELECT PARSENAME('10.0.12.13', 3) AS 'SecondOctet' UNION ALL

     SELECT PARSENAME('10.10.12.13',...

  • RE: concatenate values using an UPDATE

    I hope you are looking for this

    Give a try

    DECLARE @tbl TABLE

     (RowId  VARCHAR(20),

     RValue  VARCHAR(30),

     Lineage  VARCHAR(3000) DEFAULT '',

     Depth  INT)

     

    insert into @tbl(RowId,RValue)  values('WV', 'Kanawha')

    insert into @tbl(RowId,RValue)  values('WV', 'Putnam')

    insert into @tbl(RowId,RValue)  values('WV', 'Dodridge')

    insert into @tbl(RowId,RValue)  values('WV', 'Rhone')

    insert into @tbl(RowId,RValue)  values('OH', 'Buckeye')

    insert...

  • RE: How can I remove newline character from a string

    Try this

    DECLARE @STR VARCHAR(20)

    SELECT @STR = 'HELLO'+CHAR(10)+'HELLO'+CHAR(13)+'DDD FFF'

    PRINT @STR

    PRINT REPLACE(REPLACE(@STR,CHAR(10),''),CHAR(13),'')

     

    Ram

     

  • RE: Date formatting

    You may try like this.

    SET DATEFORMAT dmy

    GO

    SELECT CONVERT(VARCHAR(10),CAST('24-10-2006' AS DATETIME),112)

    Ram

     

     

     

  • RE: insert the value to the temp table

    Hi John,

    Appreacited, If you have really answered the below error at first sight.

    Server: Msg 2812, Level 16, State 62, Line 46

    Could not find stored procedure 'Insert into #tempTrained EmpID...

  • RE: Minimum values

    If some body has questions and gets stranded, please try to help them out and then start giving big big lectures!

  • RE: Minimum values

    Try this

    DECLARE @tbl TABLE

     (RowId INT IDENTITY(1,1),

     Col1 INT,

     Col2 INT,

     Col3 INT,

     Col4 INT)

    INSERT INTO @tbl VALUES(5,10,12,0)

    INSERT INTO @tbl VALUES(4,2,12,15)

    INSERT INTO @tbl VALUES(6,3,0,5)

    SELECT RowId,

     MinValues=

      (SELECT MIN(D1) FROM

      (SELECT CASE WHEN Col1 = 0 THEN NULL ELSE Col1 END AS D1

      UNION...

  • RE: replace() question

    Hello,

    It is a syntax error.

    Replace  "Wink" face with ")", then it will work

     

     

     

  • RE: replace() question

    Ok, Got it

    declare @table table (ad_str1 varchar(50))

    insert @table

    select 'apple avenue w' union all

    select 'melon road e' union all

    select 'watermelon circle n'union all

    select 'banana durian crossing s'

    UPDATE @table

    SET ad_str1=

     REPLACE(ad_str1,

     (

     CASE WHEN CHARINDEX(' W',ad_str1) >...

  • RE: replace() question

    Try this

    declare @table table (ad_str1 varchar(50))

    insert @table

    select 'apple avenue w' union all

    select 'melon road e' union all

    select 'watermelon circle n'union all

    select 'banana durian crossing s'

     

    select * from @table

    UPDATE  @Table

    SET ad_Str1 =...

  • RE: insert the value to the temp table

    Yep, typo... extra braces

    SET @Sql = @Sql + 'AND CTDate <= CAST('''+@todate+''' AS DATETIME)'

     

  • RE: Implementing multiple keyword search feature in site.. How to????

    Hi

    Try this

    DECLARE @ProdList VARCHAR(100)

    SET @ProdList = 'regulations leaves employee'

    SELECT *

    FROM Regulations AS REG

     INNER JOIN Reason AS REAS

      ON REG.Reg_ID = REAS.Reason_Reg_Id

      AND ((CHARINDEX(CONVERT(NVARCHAR,REG.Reg_Name),@ProdList) > 0)

      OR (CHARINDEX(CONVERT(NVARCHAR,REG.MaxDuration),@ProdList) > 0)

      OR (CHARINDEX(CONVERT(NVARCHAR,REG.Reason_Text),@ProdList) > 0))

     INNER JOIN Eligibility AS ELIG

      ON REG.Reg_ID = ELIG.Elig_Reg_ID

      AND (CHARINDEX(CONVERT(NVARCHAR,ELIG.Eligibility_Text),@ProdList) >...

Viewing 15 posts - 16 through 30 (of 81 total)