Forum Replies Created

Viewing 15 posts - 1,966 through 1,980 (of 3,544 total)

  • RE: Formatting Output

    Beware of rounding, ie

    DECLARE @number numeric(9,5)

    SET @number = 60.99999

    SELECT @number,CAST(@number AS numeric(6, 2))

    result

    60.99999 61.00

    SELECT @number,CAST(ROUND(@number,2,1) AS numeric(6, 2))

    result

    60.99999 60.99

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: box like charecter

    Just to pitch in

    SELECT CAST([columnname] as varbinary(8000))

    will display the string in hex and you can see what and how many non printable...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Spilt excel file into multiple excel files

    CREATE TABLE #temp (location int, [name] varchar(40), DOB datetime)

    INSERT INTO #temp (location, [name], DOB)

    SELECT location, [name], DOB

    FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',

    'Excel 8.0;HDR=YES;Database=C:\temp\book1.xls', [sheet1$])

    DECLARE @location int

    SELECT @location =...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Create/export csv file from sql server table

    or use BCP

    exec master..xp_cmdshell 'bcp database.owner.tablename out outputfilename -c -t "," -S servername -T'

     

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Spilt excel file into multiple excel files

    in TSQL

    INSERT INTO

    OPENROWSET('Microsoft.Jet.OLEDB.4.0',

    'Excel 8.0;HDR=YES;Database=C:\temp\book2.xls', [sheet1$])

    (location, [name], DOB)

    SELECT location, [name], DOB

    FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',

    'Excel 8.0;HDR=YES;Database=C:\temp\book1.xls', [sheet1$])

    WHERE location = 'locationwanted'

    the only caveat with this method is...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Return Code with isql, osql or isqlw

    Try this

    osql -S <server> -E  -b -m-1 -i <not_changeable_sql_script.sql> -o <output>

    IF ERRORLEVEL 1 GOTO ERROR_LABEL

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: SQL query problem

    WHERE @col1 LIKE 'abc_def'

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Update Table for records up to a specified quantity

    quote...but your solution uses some implicit assumptions that are not given ...

    But your observations are assumptions also,...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Update Table for records up to a specified quantity

    UPDATE a

    SET a.[Scheduled Amount] = a.[Scheduled Amount] + CASE WHEN (@Qty - b.Summ) > (a.Quantity - a.[Scheduled Amount]) THEN (a.Quantity - a.[Scheduled Amount]) ELSE (@Qty - b.Summ - a.[Scheduled...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Update Table for records up to a specified quantity

    No problem

    I had to look twice myself just to make sure

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Update Table for records up to a specified quantity

    quoteA little tweak to seems (to me) to meet all the requirements (including the priority one)...

    My solution...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Update Table for records up to a specified quantity

    a possible solution

    DECLARE @Material NVarChar(32), @Qty int

    SET @Material = 'MATERIAL1'

    SET @Qty = 350

    UPDATE a

    SET a.[Scheduled Amount] = CASE WHEN (@Qty - b.Summ) > a.Quantity THEN a.Quantity ELSE (@Qty -...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: 5 Table Join

    Just guessing  but I think the problem is the join between PartRace and IndResults not matching on RaceID

    SELECT p.ParticipantID, pr.Age, ir.FnlTime, e.EventDate

    FROM Participant p...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: format data in query

    Could use if int (if not int then STR will round)

    REPLACE(STR(Amount,13,0),' ','0')

    or with decimal point

    REPLACE(STR(Amount,13,2),' ','0')

    or without decimal point but including decimal part

    STUFF(REPLACE(STR(Amount,14,2),' ','0'),12,1,'')

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Removing High Ascii (>128)

    If the fields are varchar then

    create the numbers table thus

    CREATE TABLE [numbers] (number int PRIMARY KEY CLUSTERED)

    and populate with numbers from 1 to 8000

    and use

    DECLARE @result varchar(8000)

    SET @result...

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 15 posts - 1,966 through 1,980 (of 3,544 total)