Forum Replies Created

Viewing 15 posts - 646 through 660 (of 2,007 total)

  • RE: String Manipulation - Please help

    DECLARE @str1 CHAR(6) = 'Lokesh', @str2 CHAR(5) = 'Gowda';

    --View current values

    SELECT @str1, @str2;

    --Update the variables

    SET @str1 = LEFT(@str1,3)+REPLICATE('*',LEN(@str1)-3);

    SET @str2 = LEFT(@str2,3)+REPLICATE('*',LEN(@str2)-3);

    --View new values

    SELECT @str1, @str2;

  • RE: Help with a query? Parent - Child hierarchy problem

    lewisdow123 (5/24/2012)


    The id is a primary key with automated self incrementing identity, so the next child will always be greater than the previous.

    That's not what you said in your original...

  • RE: Help with a query? Parent - Child hierarchy problem

    lewisdow123 (5/24/2012)


    Hi,

    I'm hoping someone will be kind enough to give me a hand on a little problem I have.

    Basically we a relationship table, that uses a parent-child association, this table...

  • RE: How to check if a comma seperated column contains the desired word

    Jeff Moden (5/23/2012)


    Of course, that's also why I generally don't allow XML in any of my databases. 😀

    I wish I had the authority to enforce that sort of rule

    dwain.c (5/22/2012)


    Cadavre...

  • RE: ascending numbers

    ColdCoffee (5/22/2012)


    using System;

    using System.Data;

    using System.Text;

    using System.Data.SqlClient;

    using System.Data.SqlTypes;

    using Microsoft.SqlServer.Server;

    public partial class UserDefinedFunctions

    {

    [Microsoft.SqlServer.Server.SqlFunction]

    public static SqlInt32 SortDigits(SqlInt32 Number)

    {

    ...

  • RE: ascending numbers

    SQLKnowItAll (5/22/2012)


    Cadavre (5/22/2012)


    Bit of a guess: -

    SELECT Num,

    ((SELECT bits

    FROM (SELECT SUBSTRING(CAST(Num AS VARCHAR(19)),n,1),

    Num

    ...

  • RE: ascending numbers

    SQLKnowItAll (5/22/2012)


    Very nice! Now the question plaguing me is... Why on earth would we want to do this?!

    The only reason that springs to mind is interview/homework question to see if...

  • RE: ascending numbers

    Bit of a guess: -

    SELECT Num,

    ((SELECT bits

    FROM (SELECT SUBSTRING(CAST(Num AS VARCHAR(19)),n,1),

    Num

    FROM #Number...

  • RE: Updating Comma Delimited Field

    I agree with the previous statements made, you are going to have many difficulties.

    However, your current design can be used if it absolutely has to.

    SELECT MRN, additional_procedure, additional_procedure_Location,

    STUFF((SELECT ','+

    ...

  • RE: Sintax error, stopred procedure

    Or do it in one go -

    DECLARE @sql NVARCHAR(4000);

    SELECT @sql =

    'exec master.dbo.xp_cmdshell ''rmdir "c:\tempo_SGCTLOCAL\"'', no_output;'+CHAR(13)+CHAR(10)+

    'exec master.dbo.xp_cmdshell ''mkdir "c:\tempo_SGCTLOCAL\"'', no_output;'+CHAR(13)+CHAR(10)+

    'exec master.dbo.xp_cmdshell ''MOVE '+@caminho+'*.* c:\tempo_SGCTLOCAL'', no_output;'+CHAR(13)+CHAR(10)+

    'exec master.dbo.xp_cmdshell ''rd /s/q '+@caminho+''', no_output;'+CHAR(13)+CHAR(10)+

    'exec master.dbo.xp_cmdshell...

  • RE: How to check if a comma seperated column contains the desired word

    dwain.c (5/22/2012)


    Doesn't work obviously! Note the statement at the end of my post, which I put there suspecting that the data in the catenated string may not be very...

  • RE: How to check if a comma seperated column contains the desired word

    dwain.c (5/21/2012)


    If you're trying to join the two tables based on common names, you can also use PATINDEX.

    Create table #basetable(Id int identity, Component varchar(256))

    Create table #dailytable(ID Int, FILENAME Char(50), PROCESS...

  • RE: Error performing Count Text Data Column

    Much easier to answer you now.

    SELECT '#TmpAct' AS TableName, 'ACCOUNT_ID' AS ColumnName,

    COUNT(DISTINCT b.ACCOUNT_ID) AS NumDistinctValues,

    MIN(c.ACCOUNT_ID) AS MinValue,

    MAX(c.ACCOUNT_ID) AS MaxValue

    FROM #TmpAct a

    CROSS APPLY (SELECT CAST(a.ACCOUNT_ID AS VARCHAR(MAX))) b(ACCOUNT_ID)

    CROSS...

  • RE: Error performing Count Text Data Column

    Welsh Corgi (5/21/2012)


    It is close. It returns 9 as the Min value when it should be 8.

    I'm using a concatenate function in Excel.

    Without DDL and sample data that reflects what...

  • RE: Error performing Count Text Data Column

    Total guess having not seen sample data or DDL.

    SELECT TableName, ColumnName, COUNT(ColumnName) AS DistinctValues,

    MIN(MinValue), MAX(MaxValue)

    FROM (SELECT

    'ACCOUNT' AS TableName,

    ...

Viewing 15 posts - 646 through 660 (of 2,007 total)