Forum Replies Created

Viewing 15 posts - 2,446 through 2,460 (of 2,463 total)

  • RE: Renamed AD users' accounts, now some SQL Servers can't get info

    schleep (7/11/2012)


    We changed some users AD accounts to a new name (samaccountname, displayname, logon, etc..)

    On one SQL server (2 instances), we get the following error on setuser.

    Could not obtain information...

    "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: Converting yyyy/mm/dd hh:mm:ss

    sqluser_8119 (7/11/2012)


    How do you make this:

    yyyy/mm/dd hh:mm:ss

    Look like this:

    mm/dd/yyyy hh:mm --hh:mm needs to be in military time

    DECLARE @date datetime = '2012/06/20'

    SELECT CONVERT(CHAR(10), CONVERT(datetime, @date,103),101)

    "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: Loop within a Loop

    SGT_squeequal (7/11/2012)


    Racking my brains on this one, does anyone know if it is possible to do a while loop with in a while loop?

    what i want to do is...

    "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: SQL Variable IF Clause

    SQLSeTTeR (7/11/2012)


    Alan - Thank you very much. This did the trick.

    No problem.:cool:

    "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: SQL Variable IF Clause

    Sony Francis @EY (7/11/2012)


    We can simplify the above query to

    select @v-2 =case when t1.col2 like '%*%' then t2.col2 else t1.col2 end

    from @table1 t1,...

    "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: SQL Variable IF Clause

    I think this is what you are looking for:

    DECLARE @d1int = 1,

    @v-2 varchar(2);

    DECLARE @table1 TABLE

    (

    idint,

    col2varchar(2)

    );

    DECLARE @table2 TABLE

    (

    idint,

    col2varchar(2)

    );

    INSERT INTO @table1

    VALUES (1,'aa'),(2,'bb'),(3,'d*')

    INSERT INTO @table2

    VALUES (1,'xx'),(2,'yy'),(3,'zz')

    SELECT @v-2 = col2 FROM @table1 WHERE...

    "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: Urgent help needed, Max Growth by DB

    You mean 128. Yes, that is correct. Thanks!

    "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: Urgent help needed, Max Growth by DB

    To get the number in MB:

    value * 8 / 1024

    Example:

    Selectname,

    size*8/1024

    from sys.master_files

    "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: Urgent help needed, Max Growth by DB

    Everything except for the DB name can be found in sys.database_files. You can get db name with DB_NAME(). The procedure below will get you all this information for every DB...

    "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: Searching Database for spesific column in all tables

    Beginning with SQL Server 2005, they included the INFORMATION_SCHEMA which is a better way to access this kind of information.

    For columns you can use INFORMATION_SCHEMA.COLUMNS which, unlike sys.columns, provides 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: Searching Database for spesific column in all tables

    I also concur with Richard Warr's post. Redgate has a great tool for searching databases and the contents of databases (something worth noting, especially on SQLServerCentral.)

    "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: Searching Database for spesific column in all tables

    If we are talking about searching for tables specifically here then you could use these:

    The first one, usp_findColumn_thisDB, takes a parameter and searches all tables with a column matching that...

    "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: Removing possible bad Indexes

    With a couple very rare exceptions (not relevant for this conversation) I have never had any issues with disabling indexes.

    "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: Removing possible bad Indexes

    Based on what you've said I cannot see any use for them but I would I would disable them first for a little while to be on the safe side...

    "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: Removing possible bad Indexes

    Determining the performance impact of removing these unused indexes is important; understanding the impact of leaving them there is also important. In the past 14 years I cannot recall a...

    "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,446 through 2,460 (of 2,463 total)