Forum Replies Created

Viewing 15 posts - 106 through 120 (of 422 total)

  • RE: Shred XML with 4 level hierarchy into SQL Server table

    Here's a stored procedure that will shred the XML into a table. I had to add a set of <body></body> tags below the root but otherwise your XML parsed perfectly.

    [The...

  • RE: Sequential numeric

    Try this:

    IF OBJECT_ID('tempdb..#TempTable') IS NOT NULL

    DROP TABLE #TempTable;

    CREATE TABLE #TempTable

    (seq_nbr INT IDENTITY(1,1), dx_code1 VARCHAR(6),dx_code2 VARCHAR(6),dx_code3 VARCHAR(6),dx_code4 VARCHAR(6))

    INSERT INTO #TempTable (dx_code1,dx_code2,dx_code3,dx_code4)

    VALUES('366.16','362.52','370.03','362.52')

    --SELECT * FROM #TempTable

    IF OBJECT_ID('tempdb..#diag_codes') IS NOT...

  • RE: How to make this block dynamic?

    erikd (7/7/2013)


    I'm just not sure how to do it.

    When I run:

    select @liststr = coalesce(@liststr+',' ,'') + quotename(column_name)

    from [server].j3688802s.information_schema.columns where table_name = 'sample'

    print (@liststr)

    I get a list of column names like...

  • RE: Column Order in an Index

    pdanes (7/5/2013)


    I'm getting a little tired of all the jerkoffs who immediately jump in with comments like "You shouldn't be writing SQL code." Do you suppose anyone believes you were...

  • RE: SQL to combine rows based on dates and other common factors

    IF OBJECT_ID('tempdb..#Something') is not null

    DROP TABLE #Something

    CREATE TABLE #Something

    (

    ID int,

    Employee varchar(20),

    Job varchar(20),

    StartDate datetime,

    EndDate datetime,

    Workload int

    )

    INSERT #Something

    SELECT *

    FROM (VALUES

    (1, 'John Doe', 'HSBC', '01/01/2013', '31/12/2013', 100)

    ,(2, 'John Doe', 'Vacation', '17/06/2013', '21/06/2013', 100)

    ,(3,...

  • RE: split a string

    Parsing addresses (and names) is perhaps one of the trickiest tasks in SQL. There's really no sure fire way to take a name or address that was originally placed in...

  • RE: Urgent help with Date comparison in TSQL

    dhananjay.nagarkar (7/2/2013)


    Dear friends,

    I have requirement - to retrieve order from database that were created before 12:00 AM GMT on June 3, 2013.

    I'm using datediff but it is giving...

  • RE: NULL datetime field. Is it possible?

    IF OBJECT_ID('tempdb..#TempTable') IS NOT NULL

    DROP TABLE #TempTable

    CREATE TABLE #TempTable (

    [ID] INT IDENTITY(1,1) NOT NULL,

    [SentDate] DATETIME NULL,

    PRIMARY KEY (ID))

    INSERT INTO #TempTable

    SELECT RandomDate

    FROM (

    ...

  • RE: substring comparison for last 2 characters

    Create some sample data:

    IF OBJECT_ID('tempdb..#SampleData') IS NOT NULL

    DROP TABLE #SampleData

    CREATE TABLE #SampleData (

    [ID] INT IDENTITY(1,1) NOT NULL,

    [strVal] NVARCHAR(50) NULL,

    ...

  • RE: Need some help in solving the below logic of averages

    Maybe this will take you in the right direction. I generated a bunch of random numbers to make a larger sample.

    Sample data:

    -- [You will need to create some functions to...

  • RE: Insert Multiple rows using Transacrtions

    Vedran Kesegic (6/29/2013)


    Also, there is no "end tran" command, you probably meant "commit tran".

    You are correct about COMMIT TRAN. It was late after a long day! :blush:

     

  • RE: Insert Multiple rows using Transacrtions

    sankar.nandakumaran (6/28/2013)


    Hi..

    I have a table and need insert multiple data into it. First i have delete all data into the table and then insert...

  • RE: Need to implement proper case function in SSIS

    This is still a work-in-progress and hasn't been tested thoroughly, though it seems to work pretty well. I've been planning to write an article on the proper-casing problem and this...

  • RE: Need to implement proper case function in SSIS

    manibad (6/28/2013)


    If we have any other way to achieve the what I desired please suggest me..

    What I need in the end is I have to achieve the Proper case functionality...

  • RE: sp_spaceused rewritten as one query (no cursors)

    Very nice! Added to my utility "tool box."

    For Caruncles: If you have a situation where your db is running out of alloted space (such as on a 3rd-party shared server)...

Viewing 15 posts - 106 through 120 (of 422 total)