Forum Replies Created

Viewing 15 posts - 6,706 through 6,720 (of 8,731 total)

  • RE: Finding the longest string within a string field

    I can't test this right now because I don't have a 2012 instance available, but it uses Eirikur's idea.

    WITH e1(N) AS(

    SELECT N FROM (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0))e(N)

    ),

    e2(N) AS(

    SELECT a.N FROM e1 a, e1...

    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 the longest string within a string field

    Eirikur Eiriksson (3/21/2014)


    Just a quick thought;

    Splitting the string is somewhat like crossing the stream for a sip of water, when all that is needed is to get the position of...

    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: How to run dynamic query which is the output of another query ?

    There are 2 options available:

    DECLARE @sql varchar(8000) = '';

    --Option 1

    select top 3

    @sql = @sql + 'select top 3 * from '+name + CHAR(10)

    from sysobjects where type =...

    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: How to run dynamic query which is the output of another query ?

    Assign it to a variable and execute the variable with sp_executesql or EXEC().

    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: Count 2 if met criteria

    That's not what I asked for. I need table definitions and sample data in a way that I can copy and paste them in SSMS and use them without any...

    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: Are the posted questions getting worse?

    Congratulations Jason, that sounds great.

    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: Steps to tune a specific query

    These are my observations about your answer, they're not wrong but I can partly understand the interviewer.

    first, check whether the query is using index? If yes, check it is a...

    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 prblem in sql server

    You're looking for CROSS TABS or PIVOT. Take a look at this article to know more about it: http://www.sqlservercentral.com/articles/T-SQL/63681/

    Here's an example:

    SELECT id , name,

    SUM(...

    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: How to format a query

    Another option is to use http://poorsql.com

    It has SSMS and notepad++ plugins plus, plus a stand-alone formatter.

    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 returns no records unless I add a date range to the WHERE clause

    Koen Verbeeck (3/21/2014)


    In your second query, you also left out the data range where clause in the subquery on [dbo].[tblClientLog].

    This means you will now have the entire table of tblclientLog...

    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: String Concat in Group

    steve.spenceST (3/20/2014)


    🙂 Thank you for this answer. Helped me greatly.

    Note that there are better ways of doing this. As explained in here: http://www.sqlservercentral.com/articles/comma+separated+list/71700/

    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: Count 2 if met criteria

    Sure, you can do many things, but we need some help from you. Could you post sample data, and expected results in the form of CREATE TABLE and INSERT statements?...

    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: Suggested order of learning for Stairways

    I would suggest that you start with Stairway to Data[/url], continue with Database Design[/url] to understand SQL objects, then T-SQL DML[/url] and continue with whatever you're interested as the topics...

    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 the longest string within a string field

    If I understand correctly, you want to check if there's a continuous character string in the column, it doesn't matter the position of it.

    You could do this with a string...

    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: LEFT JOIN not returning anticipated results from Left table in query

    Your WHERE clause is converting your LEFT JOIN into an INNER JOIN.

    You need to change your query a little bit.

    Here's a nice article on the subject: http://www.sqlservercentral.com/articles/T-SQL/93039/

    SELECT Users.Code AS FE

    ,COUNT(Matters.FeeEarnerRef)...

    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 - 6,706 through 6,720 (of 8,731 total)