Forum Replies Created

Viewing 15 posts - 286 through 300 (of 395 total)

  • RE: Weird Requirement... Multiple Left Joins? Am I missing something?

    CptCrusty1 (8/28/2012)


    Laurie,

    Thanks for your reply. The "Values" reserved word didn't fly in 2005. Is that a 2008+ term?

    Thanks

    Crusty

    Hi - Sorry about that, but you've posted in the SQL...

  • RE: Weird Requirement... Multiple Left Joins? Am I missing something?

    select Doc.DocNum, GR.GR, GR_Seq = GR.Seq, GE.GE, GE_Seq = GE.Seq, Ref.Ref, Ref_Seq = Ref.Seq

    from Doc

    cross join ( values (1),(2),(3),(4),(5),(6),(7),(8),(9) ) N (n)

    left outer join GR on GR.DocNum = Doc.DocNum and...

  • RE: Nested Select

    rothj (8/28/2012)


    Thanks for your response Laurie.

    That is how I was initially attempting to get it done but I was struggling with the Cross Apply.

    I appreciate your method.

    Post your cross apply...

  • RE: Nested Select

    rothj (8/28/2012)


    Thank You Andy, that does give me the desired outcome.

    I apologize but I left out one detail.

    There are other Obsv Codes that begin with A_Med1 etc. (like...

  • RE: Nested Select

    Another possibility:

    --===============================================================================================

    -- Test data:

    --===============================================================================================

    drop table dbo.Medication;

    create table dbo.Medication

    (

    obsv_cd varchar(30),

    obsv_cd_name varchar(10),

    med_name varchar(30),

    med_status varchar(30)

    );

    insert into dbo.Medication values ( 'ABCDEFG111', '', 'Name1', '' );

    insert into dbo.Medication values ( 'ABCDEFG111', 'Status', '', 'New' );

    insert...

  • RE: Selecting records based on string search

    The layout for a store procedure is like this:

    create procedure dbo.STORED_PROC_NAME

    (

    @sstrg varchar(100)

    )

    as

    begin

    set nocount on;

    --declare @strg varchar(100) = 'Catalog',

    declare

    @sstring varchar(100),

    @sstrg1 varchar(100),

    @sstrg2 varchar(100)

    begin

    set @sstring = @sstrg

    if @sstring like '%*%'

    begin

    set...

  • RE: Delete script help

    No problem.

    I learned something too:

    I'll put proper notes in the script to explain what I'm doing next time!

  • RE: Delete script help

    Hi

    Creating & deleting the table is just to set up the test data.

    You would only run the WITH CTE AS... statement.

    The select is to look at the results.

    It's just to...

  • RE: Split a name on to new columns in a table

    Will the names always be in the same format TITLE/FIRST/SECOND, or could you have middle names & missing titles, for example?

  • RE: SQL SERVER Performance

    If you know already which query is running slowly, you could post it here & let people have a look at it.

    It might have obvious problems which could be pointed...

  • RE: Delete script help

    OK - I didn't notice the BOE_BOERNIDs were out of order. This should handle it:

    drop table dbo.boern

    create table dbo.boern

    (

    BOE_BOERNID int,

    boe_fornavn varchar(10),

    boe_institution varchar(30)

    );

    insert into dbo.boern values ( 1539,...

  • RE: Delete script help

    Try this:

    ;WITH CTE AS

    (

    select TOP 1000000 BOE_BOERNID,

    boe_fornavn

    from dbo.boern

    where boe_institution = 'Fritidsklub 4/5 kl.'

    order by BOE_INSTITUTION,BOE_FORNAVN,BOE_BOERNID

    )

    DELETE CTE

    WHERE boe_Boernid >= 1682;

    deleting from the CTE deletes from the underlying...

  • RE: Statement Failures Within TRANSACTIONS

    Thinking about it, you can set up automatic transactions, although I've never done it:

    http://msdn.microsoft.com/en-us/library/ms188792.aspx

  • RE: Statement Failures Within TRANSACTIONS

    raotor (8/28/2012)


    Hello,

    Am I going to have to use BEGIN TRY ... CATCH blocks and ROLLBACK whenever I want a transaction to cleanly rollback when an error occurs?

    This is the normal...

  • RE: replace

    You can do this:

    SELECT REPLACE('0,0,'',0,'',0', '0,0', '0,NULL')

    This will be OK as long as the pattern only occurs once in the string.

Viewing 15 posts - 286 through 300 (of 395 total)