Forum Replies Created

Viewing 15 posts - 7,861 through 7,875 (of 8,731 total)

  • RE: Is it possible to return a value from a SP like this?

    You could use something like this.

    DECLARE @median sysname,

    @tablenm sysname

    declare @sql nvarchar (max),

    @med decimal(15,2)

    set @sql = 'WITH MEDCTE (ID, MED)

    AS (SELECT

    Id,

    AVG( ' + QUOTENAME(@median)...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Help with query

    You don't need a cursor or a cycle. There's an easier, shorter and quicker way to do it.

    You can read about it on this article. http://www.sqlservercentral.com/articles/comma+separated+list/71700/

    SELECT CompanyCode,

    Login = STUFF((

    ...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Using DelimitedSplit8k against a Space Delimited Field - Problems

    You might have a character that might not be a space.

    You can check which character is with this code (it's untested, but it should work).

    WITH E1(N) AS (

    ...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Trying to convert varchar to datetime

    You could try something like this

    DECLARE @cDate varchar(5) = '20114'

    SELECT DATEADD( MONTH, RIGHT(@cDate, 1) , CAST( LEFT(@cDate,4) + '0101' as DATE))

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Trying to convert varchar to datetime

    2011401 does not have a common format for a date. Can you explain which is the year, month and day?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Need procedure to delete .bak

    stillconfused (7/23/2013)


    Hi,

    I found the below link which describes useful undocumented stored procedures. Does it mean to be good to use

    EXECUTE xp_delete_file 0|1, 'file_name'

    Which link?

    As I said, there are some risks...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Using a Temporary Table in a View in Order to Combine three Queries

    You could use CTEs instead of the temporary tables. However, you should check for any possible performance issues.

    WITH MOVEMENTS AS(

    SELECT *

    FROM [GW_DW].[dbo].[DimStatusHistory] d

    WHERE TransferFromToProgram <> ''

    AND d.STATUS = 12

    ),

    NEW_MOVEMENTS...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Need procedure to delete .bak

    Check for something like this. If you have problems, it might be a permissions problem.

    EXEC xp_cmdshell 'DEL "C:\My\Full\Path.bak" /Q';

    GO

    I wouldn't advice to use undocumented procedures on a production environment, but...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Need procedure to delete .bak

    You could try using xp_cmdshell 😉

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Group by based upon condition

    You'll always be welcome here to learn as we all learn here.

    The error you're getting is because the rollno on the order by is not qualified. Just add "s." before...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Group by based upon condition

    Sean Lange (7/23/2013)


    I didn't just provide a solution because this looks so much like homework and the OP did not answer that one way or the other.

    If this post was...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Group by based upon condition

    I didn't read the previous posts. The idea is really similar, but I'm not using a temp table (I probably should). This would be a lot easier on 2005+

    SELECT s.*...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: search values in a temp table with like operator

    Scott,

    I believe that Sue is mentioning the CTE that's included in the 8K Splitter that I mentioned.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: do I need to use case explicily

    You don't need to cast it, an implicit conversion will transform strings into integers if the column only contains digits. If there's a non-integer value in your column, it will...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: SQL doesn't see .bak file?

    Are you checking that the .bak file exists on the server and not on your desktop?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 15 posts - 7,861 through 7,875 (of 8,731 total)