Forum Replies Created

Viewing 15 posts - 2,701 through 2,715 (of 8,731 total)

  • RE: Create SP to add new column based on other table data.

    Steve Jones - SSC Editor (6/13/2016)


    However, you need to do this in an idempotent way. You don't want to run

    ALTER TABLE mytable add mycol int

    and there already be a mycol...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Stored Procedure throws Violation of PRIMARY KEY constraint when called concurrently whit same parameters

    ChrisM@Work (6/13/2016)


    Y.B. (6/13/2016)


    Maybe something like this would be better suited...

    IF EXISTS (SELECT 1 FROM SomeTable WHERE ID = @id)

    UPDATE SomeTable SET SomeText = @SomeText

    ELSE

    INSERT INTO SomeTable VALUES (@ID, @SomeText)

    EDIT: Although...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Create SP to add new column based on other table data.

    This is a scary idea. I'm not sure that letting people modify the schema.

    That being said, it could be done by using a trigger and dynamic SQL.

    As I'm against this...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Creating #Table

    It seems like you're looking for the syntax from this example.

    CREATE TABLE TableA( id int identity, value varchar(100), somedate datetime DEFAULT GETDATE());

    INSERT INTO TableA(value) SELECT 'One Value';

    CREATE TABLE TableB( id...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Need ssis expression

    Use the conditional.

    TOKEN( @[User::AgeBucket],"-",1) == @[User::AgeBucket] ? TOKEN( @[User::AgeBucket],"+",1) : TOKEN( @[User::AgeBucket],"-",1)

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Today's Random Word!

    Ray K (6/10/2016)


    Ed Wagner (6/10/2016)


    HappyGeek (6/10/2016)


    Revenant (6/10/2016)


    djj (6/10/2016)


    ThomasRushton (6/10/2016)


    Ed Wagner (6/10/2016)


    djj (6/10/2016)


    Grumpy DBA (6/10/2016)


    Ed Wagner (6/10/2016)


    HappyGeek (6/10/2016)


    ThomasRushton (6/10/2016)


    Stuart Davies (6/10/2016)


    Ray K (6/9/2016)


    Hugo Kornelis (6/9/2016)


    Poke

    Owwww!

    Pain

    Neck

    Polo

    Horse

    Glue

    Gun

    Gatling

    Nerf

    Soft

    Ware

    Goods

    Sporting

    Kansas City

    Chiefs

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Simple Store Procedure for delete rows in a SQL 2012 table

    Are you aware of the TRUNCATE TABLE statement? It might be a better option if you're deleting all the rows in a table.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Cannot insert nulls in oledb destination table selecting "ignore" on destination columns

    You could also use a derived column to insert a default value to those columns.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Row number with Pivot

    kevin 26531 (6/10/2016)


    Thanks Chris but it's a dynamic query. There could be 10 columns (after the pivot) or 100 so I can't hardcode fields into the script.

    Had thought about...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Are the posted questions getting worse?

    Brandie Tarvin (6/10/2016)


    ThomasRushton (6/10/2016)


    Am I being unreasonable in now thinking "perhaps you're not the one who should be doing this"?

    I'm going to say Yes only because DB Mail is incredibly...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Stats_date()

    The title was a big hint. I just had to make sure it wasn't misleading. 😀

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Tools to load fields into a query

    Yes.

    Import/Export wizard

    SSIS Packages

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Displaying Column Data Horizontally Using Pivot Table

    I'll just leave this here. Be sure to understand the solutions or you'll have lots of trouble maintaining them.

    You might want to read the following articles:

    http://www.sqlservercentral.com/articles/CROSS+APPLY+VALUES+UNPIVOT/91234/

    http://www.sqlservercentral.com/articles/T-SQL/63681/

    http://www.sqlservercentral.com/articles/Crosstab/65048/

    DECLARE @sales TABLE(

    ...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Interview Questions

    patrickmcginnis59 10839 (6/9/2016)


    I don't understand, if you don't care if its right, and additionally the applicant can apply zero thought to it and its still acceptable, whats the takeaway for...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: FLAG

    There's no way to know if it changed from 3 to 2 or from 2 to 3. There's no way to define the order in that table.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 15 posts - 2,701 through 2,715 (of 8,731 total)