Forum Replies Created

Viewing 15 posts - 856 through 870 (of 2,007 total)

  • RE: Column Alias name dynamically

    fahey.jonathan (2/24/2012)


    Cadavre: Here is another way to generate the table:

    OK, I'll play. . .

    Your code:

    SET STATISTICS IO ON

    SET STATISTICS TIME ON

    ;WITH t1(N) AS (SELECT 1 UNION ALL SELECT 1),

    t2(N) AS...

  • RE: script

    anthony.green (2/24/2012)


    seems to be a problem with the chars putting in &#x0D

    USE [master]; SELECT DatabaseName = DB_NAME(), CollectionD

    Sure I can figure it out, time to brush up on...

  • RE: Display monthly data into no of weeks

    Duplicate post.

    Please don't post your question twice, it fragments replies and makes it much more difficult for the unpaid volunteers of this site to help.

  • RE: how to get the Every Friday to Thursday wise data in any Month

    narendra.babu57 (2/24/2012)


    Hi the above link i can not get the solution to my query

    Hello and welcome to SSC!

    I'd like to be able to help, but it seems you've forgot to...

  • RE: split data of month into weeks

    Hello and welcome to SSC!

    I'd like to be able to help, but it seems you've forgot to post readily consumable sample data and ddl scripts.

    If you could read this article[/url]...

  • RE: Column Alias name dynamically

    Wow. . . OK.

    This will generate your 11,881,376 (!!) combinations

    SELECT a.alpha+b.alpha+c.alpha+d.alpha+e.alpha

    FROM (SELECT SUBSTRING('ABCDEFGHIJKLMNOPQRSTUVWXYZ',N,1) AS alpha

    FROM (VALUES(1),(2),(3),(4),(5),(6),(7),(8),

    ...

  • RE: script

    sp_msforeachdb is known to miss databases and has problems with names of databases (e.g. call you database "I am a [bracket]" then see what happens to sp_msforeachdb)

    This is howone way...

  • RE: If table exists, insert into

    adb2303 (2/24/2012)


    ok, will do. I thought I'd got it working previously, obviously not.

    Thanks for the suggestion

    Andrew

    The code would work if the table exists, it only fails because...

  • RE: If table exists, insert into

    Add the INSERT part into dynamic SQL then execute it from that.

    It won't work otherwise, because if the table doesn't exist then the code fails before executing.

  • RE: Are the posted questions getting worse?

    HowardW (2/23/2012)


    Is anyone here going to SQLBits X in London?

    Looking forward to some of the BI sessions as I haven't spent enough time delving into 2012 yet.

    Are there...

  • RE: Checking to see if a time is between two times

    DECLARE @start INT = 22, @duration INT = 5;

    WITH t1(N) AS (SELECT 1 UNION ALL SELECT 1),

    t2(N) AS (SELECT 1 FROM t1 x, t1 y),

    t3(N) AS (SELECT 1 FROM t2...

  • RE: FOR XML

    SELECT a.roles AS 'PEOPLE/Person/@role', a.personrole AS 'PEOPLE/Person', a.NAME AS 'PEOPLE/Name'

    FROM (VALUES ('SUPPLIER', 'Another Thing', 'Some Name1'), ('Buyer', 'Another Thing2', 'Some Name2')) a(roles, personrole, NAME)

    FOR XML path('')

    Returns

    <PEOPLE>

    <Person role="SUPPLIER">Another Thing</Person>

    ...

  • RE: FOR XML

    david.alcock (2/22/2012)


    No its OK, I left the element in above the attribute line, removing that and hey presto! End tag included. Thank you ever so much, massively appreciated.

    However,...

  • RE: Need help with a Pivot - Rows to Columns

    You haven't said how you determine which 5 to keep. In your sample data, "178976" has 6 "po_Number".

    Assuming you're using SQL Server 2000, here's one way to do it:...

  • RE: Ranking in each other

    BEGIN TRAN

    --Sample data

    SELECT X,Y

    INTO yourTable

    FROM (VALUES('A', 'B'),('A', 'B'),('A', 'C'),('A', 'C'),('A', 'C'))a(X,Y)

    --Solution

    SELECT X,Y,

    ROW_NUMBER() OVER(PARTITION BY X,Y ORDER BY X,Y) AS SEQ

    FROM yourTable

    ROLLBACK

Viewing 15 posts - 856 through 870 (of 2,007 total)