Forum Replies Created

Viewing 15 posts - 61 through 75 (of 413 total)

  • RE: Sum and percentage

    I'm not completely sure what you want, but this query produces the result you are after:

    insert [tblQuiz_Respuesta] select 2003128001, 3, 'Quellón', 25

    insert [tblQuiz_Respuesta] select 2003128001, 2, 'Castro', 197

    insert [tblQuiz_Respuesta] select...

  • RE: Sum of hours

    Much easier than what I proposed before

     

    declare @YourTable table(CodUser int, [From] int, [To] int)

    insert @YourTable select 1, 120, 240

    insert @YourTable select 1, 150,...

  • RE: Parse Varchar Field

    As I said, it's a well-known trick - I have learned it here at SSC...

  • RE: Process streamlining ideas

    You need more numbers in your #Nums table

    Apart from that, I think I would start by unpivoting data. Then I'd split it to...

  • RE: Get Time only from a Datetime Column

    Yes, I think the main problem is naming the time column. Use "as xxx", like Veeresh above. Also explicit conversion from datetime to varchar is preferable...

  • RE: UDF - Executing dynamic sql

    Try this:

    declare @count int

    declare @sql nvarchar(1000)

    declare @tablename nvarchar(100)

    select @tablename = 'yourtablename'

    select @sql = N'select @count = count(*) from ' + @tablename

    exec sp_executesql @sql,

  • RE: Parse Varchar Field

    OK, then I will write down what I had in mind

    It's a well-known trick... It's not as readable as your straightforward solution. On...

  • RE: Help me with a query

    Check out the "union" command in books online. If that doesn't help, please give us your table definition, sample data and expected output of the query.

     

  • RE: Replace carriage return in ntext(datatype) field

    "a field of datatype ntext"

  • RE: Parse Varchar Field

    Define #tempDone like Liliana defined #test, then slightly modify her code:

          insert into #TempDone SELECT NAME,

          CASE WHEN PATINDEX('%<BR>%', iq) > 0

        THEN SUBSTRING(IQ, 1, PATINDEX('%<BR>%', iq) -1)

        ELSE...

  • RE: Sum of hours

    Very nice idea, PW...

    An alternative - not at all better, but it's a different approach....

     

    declare @YourTable...

  • RE: Insert Statement incrementing value of previous record in the insert

    Well, I think what Sam should have done is the following: Define @lastitemsequence, @lastwearerid as above, then

     

    declare @FirstOldItemSequence int

    select @FirstOldItemSequence = isnull(min(itemsequence), 0) from CustomerWearerItems WHERE custid=100

    and wearerid = 1

    Insert...

  • RE: Alternate Receipts

    Is this what you are looking for?

    select

      Ind_id as [Individual ID],

      firstname as [First Name],

      lastname as [Last Name],

      occupat as Title

    from individual1

    where ind_id in

    (

      select A.payer_fk

      from contribution1...

  • RE: Checking Status of T-SQL Statements

    Perhaps examine @@ERROR after each SQL statement? Store the result in a table, then you will know which statement failed.

     

  • RE: Query help

    Try this:

    declare @table table(period int identity(1,1), begdate datetime, enddate datetime)

    insert @table (begdate, enddate) select '20060101', '20060129'

    insert @table (begdate, enddate) select '20060130', '20060228'

    select dateadd(dd, N.n, '20051231') as dateid, T.period, year(T.begdate) as...

Viewing 15 posts - 61 through 75 (of 413 total)