Forum Replies Created

Viewing 15 posts - 13,651 through 13,665 (of 15,381 total)

  • RE: Set Insert_Identity on/off

    Like this:

    create table InsertTest

    (

    ID int identity not null,

    SomeValue varchar(10)

    )

    go

    create procedure IdentityTest

    as begin

    set identity_insert InsertTest on

    insert InsertTest (ID, SomeValue) Values (10, 'MyValue')

    set identity_insert InsertTest on

    end

    go

    exec IdentityTest

    select * from InsertTest

    For...

  • RE: Set Insert_Identity on/off

    You can use that in your stored proc withOUT the need for a GO or dynamic sql. Just make sure to set it off again before you exit. 😉

    --edit correction...

  • RE: TRY CATCH is not work with BOL example

    It all has to do with the inner workings of the sql compiler. When you try to execute your example it can't compile because the table doesn't exist. It is...

  • RE: Checking for the non existence of a record

    Something like this help you get started?

    insert xref

    select c.contact_id, [All other data columns here]

    from contact c

    left join xref x on c.contact_id = x.contact_id

    where x.contact_id is null

    If you want actual code...

  • RE: How to calculate the ADX

    OK put yourself in my shoes. Do you think you have provided enough information for me to be able to help? I have asked for ddl, sample data (insert statements)...

  • RE: Passing a Var to SP that needs B-up and

    I assumed you were on 2008 since you posted in the 2008 forum. 😉 Search the forums on here. There have been a number of string split functions posted. Some...

  • RE: Passing a Var to SP that needs B-up and

    Sure.

    declare @Codes varchar(25) = '14, 8, 21458'

    ;with cte(n) as (select 1

    union all select 14

    union all select 214

    union all select 314

    union all select 15

    union all select 8)

    select *

    from cte

    where @Codes...

  • RE: Passing a Var to SP that needs B-up and

    Actually I just noticed that is fairly safe from sql injection but it does not get you the values you want.

    Declare @Type_Code varchar(50)

    set @Type_Code = '4,11,12'

    Select * from table_Type_Codes...

  • RE: Passing a Var to SP that needs B-up and

    Todd's example will also work. If you take that approach make sure you read up on sql injection because that would be vulnerable.

  • RE: How to log all queries against a database?

    a trace is pretty much the only way you can capture all queries. You can pare down the result in profiler fairly easily. You can dial it in for a...

  • RE: Wide table performance issue

    Can you provide an example of the query your are running? If possible and execution plan would help too.

  • RE: Passing a Var to SP that needs B-up and

    You need a splitter.

    Here is how the code for you case might look.

    Select * from table_Type_Codes t

    join DelimitedSplit8K([column_name], ',') s on s.Item = t.[column_name]

    For an explanation of the logic take...

  • RE: Question regarding updating a table with staging table data

    If I understand correctly, something like this should work:

    update employee_file

    set first_name = isnull(d.first_name, f.first_name),

    last_name = ISNULL(d.last_name, f.last_name),

    [rest of your columns...]

    from employee_file f

    join employee_demographics d

  • RE: Non-aggregated in aggregate function

    Amy.G (10/19/2011)


    Oops, posted that too early. Anyway, as I was saying, in the Northwind.Orders table I would like to sum the Freight column but CustomerID. I would also like the...

Viewing 15 posts - 13,651 through 13,665 (of 15,381 total)