Forum Replies Created

Viewing 15 posts - 2,431 through 2,445 (of 2,451 total)

  • RE: How do I get the all columns of a row for the row with the highest value of a column

    -- Sample code

    CREATE TABLE #T(ID INT, Unit INT)

    INSERT INTO #t

    SELECT 1,33 UNION ALL

    SELECT 2,33 UNION ALL

    SELECT 3,25 UNION ALL

    SELECT 4,55 UNION ALL

    SELECT 5,55

    -- Query

    SELECT MAX(ID) ID, MAX(Unit) Unit

    FROM #t

    GROUP BY...

  • RE: Please help me with this query

    Sean Lange (7/12/2012)


    The whole series of subselects sure makes that far more complicated than it needs to be.

    Not sure if what you posted produces what the OP wants but this...

  • RE: Please help me with this query

    I think this is what you are looking for.

    -- Sample data

    DECLARE @salesStore TABLE([CustomerID] VARCHAR(20));

    DECLARE @MyTable TABLE(val varchar(20));

    INSERT INTO @salesStore VALUES ('xxx'),('yyy'),('zzz');

    -- Insert statement

    INSERT INTO @MyTable

    SELECT * FROM

    (

    VALUES ('Store'),('CustomerID'),('int'),('10'),('Sales'),('CustomerID'),('PK_Store_CustomerID')

    )...

  • RE: Converting yyyy/mm/dd hh:mm:ss

    CELKO (7/11/2012)


    There is only one display format in ANSI SQL; the ISO-8601 version with dashes "yyyy-mm-dd HH:MM:SS.sssssss". Please notice I said display format.

    SQL is an abstract model of data. We...

  • 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...

  • 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)

  • 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...

  • RE: SQL Variable IF Clause

    SQLSeTTeR (7/11/2012)


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

    No problem.:cool:

  • 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...

  • 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 =...

  • RE: Urgent help needed, Max Growth by DB

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

  • 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

  • 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...

  • 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...

  • 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.)

Viewing 15 posts - 2,431 through 2,445 (of 2,451 total)