Forum Replies Created

Viewing 15 posts - 7,771 through 7,785 (of 8,731 total)

  • RE: Extracting a Date from a string

    As you're using SQL Server 2012, why won't you use TRY_CONVERT with a string Splitter[/url]?

    WITH CTE AS(

    SELECT TRY_CONVERT( DATETIME, Item) AS MyDate

    FROM #temp t

    CROSS APPLY dbo.DelimitedSplit8K( MyValues, ' ')

    )

    SELECT ...

  • RE: select data from a table if a column is logged with specific data

    You might be looking for something like this.

    SELECT *

    FROM( VALUES

    (CAST( '20130313 12:30' AS DATETIME), 'Total Completed =4'), /*select this*/

    (CAST( '20130313 12:00' AS DATETIME), 'Total Pending =5'),

    (CAST( '20130313 12:00'...

  • RE: left join question

    I believe that Sean, misread the queries.

    The correct answer is it depends. As Ness said, Table2 might affect the results to get duplicates.

    Here's an example.

    DECLARE @Table1 TABLE(

    col1 int,

    col2 char(1))

    DECLARE @Table2...

  • RE: How to eliminate nulls from showing in columns to the columns start at the top

    This is a weird requirement, I believe that this is a resultset and not a table as the sample data you gave us. This query might give you an idea...

  • RE: Dynamic Sorting Issue

    Actually, is not that difficult but sometimes we get stuck on the simplest things. 🙂

    Change this code as desired

    DECLARE @Sort1 varchar(10)='val3'; --NOTE: @Sort2 ommitted from this example because I...

  • RE: Pivot and Merge Columns

    I'm not sure what you need to do in the end, but this code should get you started and the article can help you to understand what's going on.

    http://www.sqlservercentral.com/articles/comma+separated+list/71700/

    WITH Parts(...

  • RE: Need help in query...

    With SQL 2012 you could use LEAD, however, you need a self join on previous versions.

    WITH Sample_Data(Number) AS(

    SELECT 10 UNION ALL

    SELECT 20 UNION ALL

    SELECT 30 UNION ALL

    SELECT 40 UNION ALL

    SELECT...

  • RE: Help Required!!

    With this code, you should be able to store these values in separate columns. Although, it expects to only have email and rota in the values. If something can be...

  • RE: Is there a better way to do this? SELECTs within a SELECT

    A simple JOIN should work.

    DECLARE @LookUpID int

    SELECT sp.SalesPersonID,

    sp.FirstName,

    sp.LastName,

    a.Address1,

    a.Address2,

    ...

  • RE: Help on inserting results into Table

    If the table already exists, you need a different approach.

    ;WITH src AS

    (

    SELECT

    database_id, db_buffer_pages = COUNT_BIG(*)

    FROM sys.dm_os_buffer_descriptors

    --WHERE database_id BETWEEN 5 AND 32766

    GROUP BY database_id

    )

    INSERT INTO MyExistingTable(

    ...

  • RE: Moving the decimal

    roryp 96873 (8/14/2013)


    Luis Cazares (8/14/2013)


    Even better would be a decimal(8,2) 🙂

    You'd get an error if you had a number that filled up that decimal(10,4) though, would you not?

    123456.7890 * 100...

  • RE: Help with Retrieving 1 Fax number

    dwain.c (8/14/2013)


    If you're after the one with the lowest POS, this should do it:

    SELECT VENDOR_ID, ADDRESS_PHONE_NUM

    FROM (

    -- Your query (reformatted)

    SELECT V.VENDOR_ID, ADDRESS_PHONE_NUM

    ...

  • RE: Help with Retrieving 1 Fax number

    I'm not sure if this will perform better, but it's another way of getting the information you need.

    SELECT V.VENDOR_ID,

    ADDRESS_PHONE_NUM

    FROM VENDOR V

    OUTER APPLY( SELECT TOP 1 ADDRESS_PHONE_NUM

    FROM ADDRESS_PHONE...

  • RE: increment id based on column value

    Could you post the actual table definition (table and column names changed if necessary) with the clustered index and the code you're using?

  • RE: Moving the decimal

    Even better would be a decimal(8,2) 🙂

Viewing 15 posts - 7,771 through 7,785 (of 8,731 total)