Forum Replies Created

Viewing 15 posts - 1 through 15 (of 51 total)

  • RE: Using parameter for different databases

    Hey Journeyman,

    Check out this stored proc:

    create procedure dbo.usp_getData

    (

     @environment nvarchar(100)

    )

    as

    begin

     set @environment = ltrim(rtrim(@environment))

     declare @errmsg as varchar(255)

     if ( isnull(@environment,'') = '' )

     begin

      set @errmsg = 'No database provided'

      raiserror...

  • RE: updating a range in a query

    Hi Larry,

    From looking at your UPDATE statement, your performance problem seems to be in the way you are updating the totalpts column in the scoring table.  The UPDATE...

  • RE: Query Timeout

    Hi sstecher,

    Although a query timeout increase is not recommended, below is the link that explains how to do it:

    for local queries:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adminsql/ad_config_5rfy.asp

    for remote...

  • RE: How to figure out the users sid?

    Hi,

    You can also do it like this:

    select suser_sid('BUILTIN\Administrators')

    Regards,

    JP

  • RE: Expanding Hierarchies......with a twist

    Hey Demicoq,

    Try to see if this is what you are looking for:

    create procedure dbo.usp_FindParentOf

    (

      @item integer,

      @parent_relation varchar(50) = 'parent'

    )

    as

    begin

      -- table to store the...

  • RE: Trigger Exception Handling

    Hey,

    Check out if the T-SQL code below is what you are looking for or helps you get there:

    create procedure dbo.usp_logError(@errcode integer, @errmsg varchar(500))

    as

    begin

      insert into error_log(errcode,...

  • RE: copying UDFs and ud dataTypes

    Hi Yogi,

    Try out these steps:

    1) Have Enterprise Manager generate a CREATE script of the UDF functions you want to move

    2) Copy the generated script code

    In SQL...

  • RE: copying UDFs and ud dataTypes

    Hi Yogi,

    It sounds like almost all your databases will be using the UDF functions. 

    Maybe, it might be less work if you just create the functions once in...

  • RE: Expanding Hierarchies......with a twist

    Hey Demico,

    I edited the SQL proc in my previous post based on the info in your last reply (refer to my previous post for the edited code, it is...

  • RE: Datatype Issues... 8000 characters is too small.

    Hi Roxanne,

    Have you tried writing VB code that uses ADO to execute your built queries?

    You would need to return the SQL queries in a resultset.  So, you...

  • RE: Expanding Hierarchies......with a twist

    Hey,

    Check out if this SQL stored proc is what you are looking or helps you get there:

    create procedure dbo.usp_getItemLevels(@item1 integer, @item2 integer)

    as

    begin

     create table #hierarchy_levels (

      parent...

  • RE: How to Get nth row from table

    Hey,

    Check if this SQL is what you are looking for:

    -- example: getting the 1000th row

    declare @N_row as bigint

    set @N_row = 1000 

    -- option to tell SQL...

  • RE: Get last order for all customers

    Hey,

    Check if this SQL gives you the results you are looking for:

    SELECT

     c.CustomerID, MAX(o.OrderID) AS OrderID

    FROM

     Customers c JOIN Orders o ON c.customerID = o.CustomerID

    GROUP BY

     c.CustomerID

    HAVING

     o.DateOfOrder = MAX(o.DateOfOrder)

  • RE: Crosstab query in Sql

    Hey,

    SQL might look something like this:

    SELECT

      Product,

      Location,

      Type,

      day_0 = SUM(CASE WHEN day = 0 THEN qty ELSE 0 END),

      day_1 = SUM(CASE WHEN day...

  • RE: Sending thousands of e-mails from SQL Server

    thank you everyone for your input ...

    msahoo, could you please post in this thread your code sample on how to call CDONTS from a stored procedure.  i know...

Viewing 15 posts - 1 through 15 (of 51 total)