Forum Replies Created

Viewing 15 posts - 1,846 through 1,860 (of 2,007 total)

  • RE: Select query

    Lowell (7/14/2010)


    turning the related rows into a comma delimited list is what you are after right?

    the easiest way is to use a neat trick using FOR XML.

    here's a nice example...

  • RE: Select query

    How about this?

    --Start by making some test data

    DECLARE @TABLE AS TABLE(

    [RequestID] INT,

    [ApprovalName] VARCHAR(35))

    INSERT INTO @TABLE([RequestID],[ApprovalName])

    SELECT 15, 'Manager'

    UNION ALL SELECT 15, 'Director'

    UNION ALL SELECT 16, 'Manager'

    UNION ALL SELECT 16, 'Director'

    UNION ALL...

  • RE: Character type number convert

    Right, I cheated a bit 😛

    --Test data

    DECLARE @TABLE AS TABLE(

    data CHAR(7))

    INSERT INTO @TABLE

    SELECT '1'

    UNION ALL SELECT '1.1'

    UNION ALL SELECT '1.1.3'

    UNION ALL SELECT '1.2'

    UNION ALL SELECT '1.2.1'

    UNION ALL SELECT '1.2.2'

    UNION ALL...

  • RE: Character type number convert

    Chris Morris-439714 (7/13/2010)


    Paul White NZ (7/13/2010)


    Chris Morris-439714 (7/13/2010)


    Paul White NZ (7/13/2010)


    Where should 1.2.10 sort, I wonder...?

    Or 1.1.3, even...

    Quite.

    Sampathsoft, please can you confirm what position 1.1.3 would assume in your sequence?

    Many...

  • RE: using SELECT CASE

    Something like this?

    DECLARE @thistime AS VARCHAR(10)

    DECLARE @shift AS VARCHAR(10)

    SET @thistime = CONVERT(VARCHAR(10), Getdate(), 108)

    SELECT @thistime,

    shift = CASE

    ...

  • RE: Character type number convert

    Paul White NZ (7/13/2010)


    Where should 1.2.10 sort, I wonder...?

    You killed both solutions 😛

    I'm thinking CHARINDEX, split on the period and sort that way?

    Chris Morris-439714 (7/13/2010)


    Or 1.1.3, even...

    I think the OP...

  • RE: Character type number convert

    Something like this?

    --Test data

    DECLARE @TABLE AS TABLE(

    data CHAR(7))

    INSERT INTO @TABLE

    SELECT '1'

    UNION ALL SELECT '1.1'

    UNION ALL SELECT '1.1.3'

    UNION ALL SELECT '1.2'

    UNION ALL SELECT '1.2.1'

    UNION ALL SELECT '1.2.2'

    UNION ALL SELECT '1.2.3'

    UNION ALL...

  • RE: Divided by zero

    Jim McLeod (7/13/2010)


    skcadavre, you've done almost exactly what mine did, but if the OP's code is part of a query, then a set-based solution (CASE) is necessary.

    I'll be honest, I...

  • RE: Only customer accounts with + & - balances

    --Sample data creation

    DECLARE @TABLE AS TABLE(

    [ID] INT IDENTITY,

    [Name] VARCHAR(50),

    [A/C] MONEY)

    INSERT INTO @TABLE ([Name],[A/C])

    SELECT 'Cust 1', -£45

    UNION ALL SELECT 'Cust 1', £80

    UNION...

  • RE: Divided by zero

    DECLARE @EXPECTEDDURATION INT

    SET @EXPECTEDDURATION = 0

    IF @EXPECTEDDURATION = 0

    BEGIN

    SELECT CONVERT(FLOAT, 1) / CONVERT(FLOAT, 1)

    END

    ELSE

    SELECT CONVERT(FLOAT, 1) / CONVERT(FLOAT,...

  • RE: sp_executesql help

    You're missing an "END", which you would've been more likely to spot had you formatted your query as below 😉

    ALTER PROCEDURE [dbo].[Sp_updateproduct]

    -- Add the parameters for the stored procedure here...

  • RE: SQL Script for Server Specs

    http://www.sqlservercentral.com/scripts/T-SQL/69348/

    --By Pradyothana Shastry, 2010/02/12

    --Step 1: Setting NULLs and quoted identifiers to ON and checking the version of SQL Server

    GO

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    IF EXISTS (SELECT * FROM dbo.sysobjects WHERE...

  • RE: Select @@ServerName not returning anything

    I don't want to sound rude, so don't take this the wrong way please 🙂

    It sounds like you're parsing the query instead of executing.

    Try pressing "F5" to execute, or go...

  • RE: Are the posted questions getting worse?

    jcrawf02 (7/12/2010)


    Lynn Pettis (7/7/2010)


    Alvin Ramard (7/7/2010)


    CirquedeSQLeil (7/7/2010)


    Alvin Ramard (7/7/2010)


    CirquedeSQLeil (7/7/2010)


    Alvin Ramard (7/7/2010)


    Jeff Moden (7/7/2010)


    I'm either getting too old or just lazier in my old age. I no longer fight...

  • RE: Select @@ServerName not returning anything

    Should work. . .

    What happens if you do

    PRINT @@ServerName

    ?

    Also, check

    SELECT *

    FROM MASTER..sysservers

Viewing 15 posts - 1,846 through 1,860 (of 2,007 total)