Forum Replies Created

Viewing 15 posts - 721 through 735 (of 2,007 total)

  • RE: Generating Test Data: Part 2 - Generating Sequential and Random Dates

    Nicely explained Jeff.

    I may have to "borrow" your method of generating random DATETIME data, my method is more difficult to understand when people glance at it. 😀

  • RE: Calculating time difference

    ChrisM@Work (4/26/2012)


    Cadavre (4/26/2012)


    ...

    The issue is that you're using formatted data in the database. Instead, you should store this as TIME or DATETIME then convert it to the correct format at...

  • RE: Calculating time difference

    Here's a very very not pretty solution.

    DECLARE @StandardHours VARCHAR(20) = '133:50:15';

    DECLARE @ActualHours VARCHAR(20) = '98:16:57';

    SELECT

    CAST(diffSeconds/3600 AS VARCHAR(6)) + ':'+ RIGHT('00'+CAST(diffSeconds%(3600)/60 AS VARCHAR(2)),2)+':'+RIGHT('00'+CAST(diffSeconds%60 AS VARCHAR(2)),2)

    FROM (SELECT

    ...

  • RE: SQL to get all Days in the month in Group by even with Zero values

    kotharibij (4/26/2012)


    Thank you Eugene.

    Both my SQL and yours (very interesting SQL), gives the same result.

    Day RegTotal

    116

    4121

    532

    636

    737

    836

    933

    1046

    1145

    I thought of a calendar table but...

  • RE: Foreach in Creating a View

    brally123 (4/26/2012)


    *btw: Is there a way to boost your point up thru your answer? I'm kinda new here in this forum.:-)

    Nope, the points are pretty meaningless here. You get 1...

  • RE: Foreach in Creating a View

    brally123 (4/26/2012)


    WOW!!! i'm just amazed on how you guys do this! Thank you so much!

    That was fantastic!

    Buuuut, I'm sorry I forgot to add this:

    foreach distinct COND in tbl_2, i would...

  • RE: Replacement for Cursors

    dwain.c (4/26/2012)


    Cadavre,

    I didn't realize that if you DECLAREd the local variables within the scope of the dynamic SQL, they would still be in scope upon return to the calling session.

    That...

  • RE: Foreach in Creating a View

    --First, let's create your sample data

    --First table

    CREATE TABLE #yourTable1 (ID INT, TAG VARCHAR(5) CHECK (TAG IN ('true','false')), COLOR VARCHAR(10));

    INSERT INTO #yourTable1

    SELECT ID, TAG, COLOR

    FROM (VALUES(1, 'true', 'WHITE'),

    ...

  • RE: Replacement for Cursors

    vinu512 (4/26/2012)


    As far as the Dynamic SQL part goes....you can't have everything always...right??

    No. The point I was trying to illustrate with the dynamic SQL I showed you, is that...

  • RE: Replacement for Cursors

    vinu512 (4/25/2012)


    Cadavre, i can accomplish that result by this query:

    Select * From Ex

    😀

    But I want the results as follows:

    Declare

    @temp1 varchar(30) = 'Jack',

    @temp2 varchar(30) = 'Vinu',

    @temp3 varchar(30) = 'Jim',

    @temp4 varchar(30) =...

  • RE: Replacement for Cursors

    vinu512 (4/25/2012)


    Suppose, I have this DDL and Sample Data:

    --DDL

    Create Table Ex(Name varchar(30) )

    --Sample Data

    Insert Into Ex

    Select 'Jack'

    Union all

    Select 'Vinu'

    Union all

    Select 'Jim'

    Union all

    Select 'Stan'

    Union all

    Select 'Ash'

    I want to loop through the...

  • RE: how to display ranking with total ranking in it

    dwain.c (4/23/2012)


    DECLARE @Sample TABLE ( Product varchar(10), City varchar(50), Sales decimal(12,2))

    INSERT INTO @Sample VALUES('12345','NewYork','20.00')

    INSERT INTO @Sample VALUES('54321','NewYork','15.00')

    INSERT INTO @Sample VALUES('54321','NewYork','9.00')

    INSERT INTO @Sample VALUES('12345','NewHaven','8.00')

    SELECT * FROM @Sample

    ;WITH cte AS (

    SELECT Product,...

  • RE: dynamic operator?

    spin (4/20/2012)


    i'm trying something like...

    myproc (@operator varchar(7), @value varchar(25))

    as

    select col1, col2 from tbl1

    where col1 @operator @value

    is this kind of dynamic deceleration possible??

    thanks

    Try something more like this: -

    CREATE myproc (@operator VARCHAR(7),...

  • RE: insert data into a table from another table, while sorting according to a field.

    salam 52473 (4/20/2012)


    Hey,

    I am making attendance management system in VS2010 with RFID technology, doing all my backend data manipulation in SQL server 2005, I know basic SQL, but I'm going...

  • RE: TOP 10 of each Division

    ColdCoffee (4/20/2012)


    Cadavre (4/20/2012)


    Vedran Kesegic (4/19/2012)


    Yes, but CTE bring limitations: it wont work in a view, and it works on less SQL versions that without CTE. So, my choice is to...

Viewing 15 posts - 721 through 735 (of 2,007 total)