Forum Replies Created

Viewing 15 posts - 5,896 through 5,910 (of 8,731 total)

  • RE: Can I use WHILE in a CTE?

    You're welcome.

    I hope that you've learned something from this. The main lesson would be that you don't need to count yourself because SQL Server will do it for you....

    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: Query into text file: bcp, dynamic SQL, temp tables and table variables

    Local temp tables and table variables will loose scope when executing xp_cmdshell. Have you tried with a global temp table? Or simply creating a permanent table.

    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: Can I use WHILE in a CTE?

    Here's my version of the code. I just added a column to your select. Be sure to understand how does it work and ask any questions that you have.

    The startdate...

    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: Can I use WHILE in a CTE?

    I haven't read all of Megha's code. I stopped at the function because that will be extremely unefficient. Check this alternative that uses an inline table valued function that 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: converting varchar to datetime

    Why are you converting to datetime and then back to varchar? Why varchar instead of char?

    SQL Server won't recognize the MMDDYYYY format as a valid date, you need to supply...

    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: Can I use WHILE in a CTE?

    This could be accomplished without a loop using the modulo operator.

    To get a coded answer, please provide DDL and sample data in a consumable format.

    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: Function to Convert Current Date to SQL Sever Date format.

    Welsh Corgi (8/29/2014)


    I want to do the Equivalent of the following SQL Select and return the result listed below:

    SELECT CONVERT(DATE,GETDATE()) AS CurrentDate;

    CurrentDate

    2014-08-29

    Thank you.

    Equivalent in Oracle?

    SELECT SYSDATE AS Datetype,

    ...

    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: Confusing with Top 1 function

    The RIGHT function is one option, you could also use STUFF function. Additionally, you could cast your result as a numeric data type.

    However, the most important thing to remember is...

    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: Can default and named instance of sql server have same port number?

    No, each instance must have its own port.

    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 server sand box

    Are you using Sharepoint Services with Access? is that possible? or is that a different MOSS?

    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: query assistance- rows to cols

    You can use cross tabs to get the results as desired. You can read about them in here: http://www.sqlservercentral.com/articles/T-SQL/63681/

    I changed your query to make it easier to read (for me)...

    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: Query column with multi values using IN

    This is one of the reasons to normalize our tables. To help you with this, I'm using a delimited string splitter (or I should say THE delimited string splitter). You...

    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: cross apply behaves like outer apply

    It's a little confuse, but the problem is that you're returning the value of a function and not a row or group of rows. Would that make sense to you?

    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 to Copy a Master Record and its detail records

    Yo need to remove the GO between both inserts. That's a batch separator and causes the variables to get out of scope.

    Beware on the use of @@IDENTITY as it can...

    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: Finding first and repeated values

    skorcher (8/26/2014)


    Thank you so much - that works!

    ...

    Would one be a recommended approach over the other?

    You're welcome.

    My recommendation would be to test both approaches. If both return the same results...

    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 - 5,896 through 5,910 (of 8,731 total)