Forum Replies Created

Viewing 15 posts - 3,646 through 3,660 (of 5,109 total)

  • RE: If statement in T-SQL

    Instead of an IF statement, why not a CASE expression?

    SELECT oi.item_name
           CASE oi.item_name WHEN 'Pen' THEN 'Accessories'
                             WHEN 'Pencil' THEN 'Accessories'
                             WHEN 'Cable'...

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • RE: Monitor job in SSIS package with T-SQL isn't working

    Phil Parkin - Thursday, June 22, 2017 7:29 AM

    Thom, I have not read your code in detail, but doesn't running a package...

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • RE: Unable to understand the Query Logic

    Could you perhaps format your code so that it's readable please? Having a CASE expression with each part on a separate line with 3 blank lines inbetween makes in completely...

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • RE: Monitor job in SSIS package with T-SQL isn't working

    This isn't editing your code, but I've had a similar problem with an SSIS task that needs to be called from the our website. When the task is kicked off,...

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • RE: SQL2017 CTP

    SQL Server 2017 is in CTP at the moment, I'm not sure it was be advisable to upgrade your current version to a test product. You would be better setting...

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • RE: How to get the monday of every week

    sgmunson - Wednesday, June 21, 2017 5:55 AM

    Try this, which  uses a CTE-based calendar table:

    WITH E1 AS (

        SELECT 1 AS N UNION...

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • RE: how can I use the new variable created by case when

    You say your have variables, but these are column names in your query. Variables start with an @ at the beginning.

    You could use a CTE to do this...

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • RE: Scalar function with source conditional to a parameter

    As Jeff suggested, a TVF would be a much better option than a Scalar funciton for performance. So you could do something like this:
    CREATE FUNCTION dbo.LastBuyer_tvf (@SC1...

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • RE: Are the posted questions getting worse?

    Ed Wagner - Tuesday, June 20, 2017 4:07 PM

    Sean Lange - Tuesday, June 20, 2017 1:23 PM

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • RE: Scalar function with source conditional to a parameter

    You're using your CASE expression incorrectly.

    Try:
    ALTER FUNCTION [dbo].[LastBuyer]
    (@SC1 varchar(30), @CIE varchar(1))
    RETURNS VARCHAR(3)
    AS
    BEGIN
    DECLARE @LB VARCHAR(3)
    SELECT @LB = CASE...

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • RE: Tsql Query help

    sqlenthu 89358 - Monday, June 19, 2017 11:55 PM

    Thanks to both of you guys. However there is no limited number of Org_ids....

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • RE: Programatically return Login name for DBO user?

    Just to point to put, that isn't exactly what you asked. That query returns a list of logins that have their default Schema set to dbo on the current database.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • RE: Programatically return Login name for DBO user?

    Do you mean?
    SELECT SYSTEM_USER AS ServerLogin, CURRENT_USER AS DatabaseUser;

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • RE: Tsql Query help

    Perhaps something like:
    CREATE TABLE #Sample
      (Org_ID varchar(20),
      Amount decimal(12,2),
      date date); --That is not confusing... </sarcasm> 😉
    GO

    INSERT INTO #Sample

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • RE: SSRSColoring

    Considering you only have one criteria for red, otherwise Green:
    =iif(Fields!ColumnA.Value <> "tempdb" AND Fields!ColumnB.Value = "y" AND IsNothing(Fields!ColumnC.Value), "Red", "Green")
    You'll need to put this expression in each cell's...

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

Viewing 15 posts - 3,646 through 3,660 (of 5,109 total)