Forum Replies Created

Viewing 15 posts - 466 through 480 (of 1,082 total)

  • RE: Select Procedure

    here are two solutions

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    ALTER PROCEDURE [dbo].[select_NewRequest] @UID int AS

    if @UID IS NOT NULL

    Begin

    SELECT [UID]

    ,[StaffNumber]

    ...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: how to get n th index of a character in a string

    try this:

    DECLARE @string VARCHAR(100)

    SET @string = 'hello/what/ru/doing?/happy/new year'

    DECLARE @Result VARCHAR(100)

    ;WITH MyCTE

    AS

    (SELECT TOP 4 SUBSTRING(@String+'/', n,

    ...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: how to get n th index of a character in a string

    Why don't you want to create the table?

    Having a tally table is very useful...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: how to get n th index of a character in a string

    cool all you need to do is change the concatenation in the last select

    DECLARE @string VARCHAR(100)

    SET @string = 'hello/what/ru/doing?/happy/new year'

    DECLARE @Result VARCHAR(100)

    ;WITH MyCTE

    AS

    ...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: how to get n th index of a character in a string

    you need to create the tally table

    SELECT TOP 11000

    IDENTITY(INT,1,1) AS N

    INTO dbo.Tally

    FROM Master.dbo.SysColumns sc1,

    ...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: how to get n th index of a character in a string

    try this:

    DECLARE @string VARCHAR(100)

    SET @string = 'hello/what/ru/doing?/happy/new year'

    DECLARE @Result VARCHAR(100)

    ;WITH MyCTE

    AS

    (SELECT TOP 4 SUBSTRING(@String+'/', n,

    CHARINDEX('/', @String+'/', n) - n) as Val

    FROM tally

    WHERE n <= LEN(@String)

    AND SUBSTRING('/' + @String,

    n, 1)...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Select Procedure

    you should have this.

    IF @P IS NULL

    rather than

    IF @P = NULL

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: special chars are retrieved .

    could we see the code ?

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Query Vs Stored Proc

    Hi Sorry about the confusion.

    In my experience I tend to notice that people who have parameter sniffing problems, tend to have it with dates. Having said this you are correct...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Query Vs Stored Proc

    Also read this thread

    http://www.sqlservercentral.com/Forums/Topic548393-8-1.aspx?Highlight=sniffing

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Query Vs Stored Proc

    one way around it is to declare a local variable and assign the value of the parameter to that variable and use that in your proc rather than the actual...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Query Vs Stored Proc

    are your parameters dates?

    If so sounds like parameter sniffing

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Trigger Question

    Look in Books online for the INSERTED AND DELETED tables.

    These are tables that hold the information of the data that is being changed.

    So you could join your table to the...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: t-sql puzzler

    am I missing something here!

    Why do you need a derived table or a CTE when it seems to be a simply Group By Having Statement?

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: t-sql puzzler

    Have you tried this?

    SELECT

    myId,

    SUM(myMoney) as Total,

    MIN(myName) as myName

    FROM [GroupingTest]

    GROUP BY myId

    HAVING SUM(myMoney) > 13

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life

Viewing 15 posts - 466 through 480 (of 1,082 total)