Forum Replies Created

Viewing 15 posts - 2,116 through 2,130 (of 2,462 total)

  • RE: Query Help

    This will get you what you are looking for...

    -- (1) Sample data

    DECLARE @x_p TABLE (xid int, nbr1 int, cid int);

    DECLARE @x_c TABLE (cid int, chr char(1), nbr2 int, nbr3 int,...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Query Needed

    Koen Verbeeck (9/26/2013)


    erikd (9/26/2013)


    Alan.B (9/25/2013)


    ...

    marky.marks;

    Made my day. 😀

    Didn't even notice it at first 😀

    I'm just happy someone noticed 😀

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Red-Gate SQL DBA Bundle

    As a DBA I used a number of tools in the DBA bundle and was a big fan.

    If you ever get a chance to attend a SQL in the...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Jobs that run during specific duration

    Below is a script that will get you information about all the jobs that ran between a two dates. I was not able to figure out how to get you...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: select truncates varchar(max) column(s)

    rightontarget (9/25/2013)


    My bad, I messed up.

    Here is what I need to run, but the output is truncated:

    drop table A;

    CREATE TABLE A(

    [col_1] [nvarchar](30) NOT NULL,

    [col_2] [varchar](256) NULL,

    [col_3] [varchar](max) NULL,

    [col_4] [varchar](max)...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Moving all Jobs on a server

    In SSMS you can right-click on the job, select "Script Job as" > "Create to" > ("Query Window" or "File"). This will produce the DDL to create each job. I...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: select truncates varchar(max) column(s)

    FYI, the sample ddl you provided had an error

    I think insert into A (col_1, col_2, col_3)

    should really be insert into A (col_1, col_2, col_3, col4)

    All that said, No truncation, simple...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Query Needed

    This is the way that I would do it.

    --Your Data

    WITH your_table AS

    (SELECT * FROM

    (VALUES

    (12402223,171906,'Quality And Reliability Engineering',1,4),

    (12402223,171906,'Quality And Reliability Engineering',2,10),

    (12402223,171906,'Quality And Reliability Engineering',3,11),

    (12402223,171906,'Quality And Reliability Engineering',4,5),

    (12402223,171906,'Quality And...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: SSRS Hide a column based on user login

    OPTION 1

    The down and dirty way (not recommended) would be to set the column visibility based on an expression like so:

    =User!UserID <> "Manager #1" AND User!UserID <> "Manager #2"

    OPTION 2

    1)...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Any *easy* way to compare database schemas, without a 3rd party tool?

    Am I going to be reduced to coding up something to list each column, its datatype, FK relationships, etc, then running it against the current and previous DB and eyeballing...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: finding value in a string

    If not for the un-closed <OrderID> tag you would have a well-formed fragment that you could query via XPath. What Scott and Sean included will be better for your requirement....

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: New dba

    I would add that it is good that you are on SQL Server Central. Use this site; it's a great resource! Ask questions, read through the forums and the articles....

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Need help in building a SQL query?

    Well done Magoo; I knew there was a much better way but drew a blank.

    Jeff Moden (9/16/2013)


    Just to backup Maggo's solution... the method he used is called a "CROSSTAB"....

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Need help in building a SQL query?

    This could still be optimized but will perform a little better than my previous query:

    --OUTPUT

    SELECT e.MSKEY AS NUMBER,

    ISNULL(fn.AVALUE,'') AS FNAME,

    ISNULL(mn.AVALUE,'') AS MNAME,

    ISNULL(ln.AVALUE,'') AS LNAME,

    ISNULL(em.AVALUE,'') AS EMAIL

    FROM Entries e

    LEFT JOIN Entries...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Need help in building a SQL query?

    Below is some DDL and a solution:

    --DDL

    USE tempdb

    IF OBJECT_ID('tempdb..Entries') IS NOT NULL DROP TABLE Entries;

    CREATE TABLE Entries (MSKEY int, ATTRNAME varchar(20), AVALUE varchar(20), primary key (MSKEY, ATTRNAME));

    INSERT Entries (MSKEY,...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

Viewing 15 posts - 2,116 through 2,130 (of 2,462 total)