Forum Replies Created

Viewing 15 posts - 241 through 255 (of 369 total)

  • RE: Query Performance

    Your procedure design is completely flawed. Do not build large "UNION ALL", but instead put required data into (temp) tables,

    and then use one simple INSERT command that joins your prepared...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: resarting row number based on values in categories

    Main problem here is that we do not have something to group on for one sequence of First, Middle, and Final.

    To solve that, I introduced a derived column that searches...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Question about Pivots in SQL Server 2008

    Since you don't know exact number of columns in a result, you need dynamic pivot.

    Something like this:

    http://www.simple-talk.com/community/blogs/andras/archive/2007/09/14/37265.aspx

    but use QUOTENAME() function.

    If you need working example, post a script that creates data...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Total idiot !

    Security is a science "per se", and there is nothing 100% secure.

    But, for your optimal/reasonable security needs probably you can do a few steps:

    - upgrade to SQL2008R2 and latest Service...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: To_Date Slow in Where Clause

    Your query contains no linked server, therefore I conclude it is pure oracle query, nothing to do with sql server, at least for now.

    You could try to use a hint,...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Grouping Problem

    If you have multiple records with the same value of number, cashdate and cashamt

    in your arcashha table, you will sum only one of that rows.

    I believe this is not desired...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: SQL SERVER question on comparing digits in different table?

    Use FULL JOIN if you want to check both directions at the same time.

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: problem with importing date&time together in the same column from excel 2003 to SQL server 2008

    Look at the CONVERT function in the documentation and various formats, and then take a SUBSTRING after conversion to varchar.

    Other approach would be without conversion to varchar, staying in the...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: MSSQL 2012 versus 2008...2000

    You can use something like this:

    RAISERROR('This is a test', 16, 1)

    Third parameter is any number you choose, from 0 to 255.

    Second parameter:

    >=16 then is error.

    <=10 and below - informational message.

    You...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Conditional joins or case statements

    You can do that like this:

    -- Input: @DistrictId or @RegionId, @startDate, @endDate

    SELECT o.RegionId, o.ItemId, SUM(o.Quantity)

    FROM dbo.Orders o

    JOIN dbo.Items i ON i.ItemId=o.ItemId

    JOIN dbo.RegionDistricts rd ON rd.RegionId = o.RegionId

    WHERE o.RequestedDate BETWEEN @startDate...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Where clause troubles with variables

    You can user ROW_NUMBER() OVER() trick:

    --=== Prepare data

    IF OBJECT_ID('tempdb..#history') IS NOT NULL drop table #history

    CREATE TABLE #history

    (HistoryId int IDENTITY PRIMARY KEY,

    ItemId int NOT NULL, -- FOREIGN KEY to item this...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: create index ... include (colx)

    You can use XDetails Addin to see included columns and other details:

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Help with XML Query please.

    Problem is that dynamic queries (exec, sp_execute) or any procedure call are not allowed in functions.

    You could build your xml without "for xml" - directly as string, then convert the...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: Help with XML Query please.

    Instead of:

    <category t1="Rifle Parts" />

    <category t2="Sights" />

    <category t3="Front Sights" />

    This would probably make more sense:

    <category t1="Rifle Parts" t2="Sights" t3="Front Sights" />

    You can achieve this by PIVOT-ing data and then converting...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths
  • RE: join query question

    Syntax is almost the same as for SELECT.

    So, if you have a select:

    --update t1 set t1.id=t2.somecolumn

    --select *

    from table1 t1

    join table2 t2 on t1.id=t2.id

    where t2.desc='solution'

    Just uncomment the line with "select",...

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths

Viewing 15 posts - 241 through 255 (of 369 total)