Forum Replies Created

Viewing 15 posts - 316 through 330 (of 898 total)

  • RE: Selection using date held as a string

    It depends on the way SQL Server processes your query

    We want the SQL Server to process the queries in the following orders

    1. Process the WHERE CLAUSE based on datatype and...

  • RE: Selection using date held as a string

    You will have to use DERIVED TABLE to do this

    SELECTTOP 10 *

    FROM(

    SELECT key_value

    ,convert(datetime2,PV.key_value) as DT2

    ,convert(datetime,CONVERT(DATETIME2, PV.key_value)) AS DT

    FROM parameter_value PV

    WHERE PV.datatype = 'D'

    ) AS PV

    WHEREconvert(datetime,CONVERT(DATETIME2, PV.key_value)) BETWEEN...

  • RE: How to select data in a particular format

    rals (4/2/2013)


    Hi,

    You can achieve this with Pivot as well..

    SELECT Certyear, [HI-Master] , [HI-Instr] , [HI-Train]

    FROM

    (SELECT Certyear,CertCode,Quantity FROM Certification) C

    PIVOT ( SUM (Quantity) FOR CertCode IN ( [HI-Master],...

  • RE: How to write custom query which shows last two records added only.

    We don't have any idea how your table structures look like and hence, it will be very difficult to assist you

    It would be really helpful if you provide the DDL...

  • RE: How to select data in a particular format

    I think this is what you are after

    SELECTv.CertYear,

    SUM( CASE WHEN v.CertCode = 'HI-Master' THEN v.Quantity ELSE 0 END ) AS QtyMaster,

    SUM( CASE WHEN v.CertCode = 'HI-Instr' THEN v.Quantity ELSE 0...

  • RE: some one write query for this problem

    You can use the DelimitedSplit8K function for your requirement

    SELECTPMI.pmid, DS.Item

    FROMPMInfo AS PMI

    CROSS APPLY dbo.DelimitedSplit8K( PMI.member, '-') AS DS

    The code for the function is present in the article by Jeff Moden...

  • RE: Columns to be included in Index

    INCLUDED columns were introduced in SQL Server 2005

    They can improve performance by avoiding key look ups as the necessary columns are included along with the key columns in the indexes

    You...

  • RE: 2 couloms from 2 dates

    What does your final expected output look like?

  • RE: Update Help..

    You can use the below mentioned query to find all un-encrypted routines using "TABLEA.ID"

    SELECTOBJECT_NAME(object_id) AS RoutineName

    FROMsys.sql_modules AS sm

    WHEREsm.definition LIKE '%TABLEA.ID%'

    You can then manually changes all the SP's

    I would suggest you...

  • RE: Find a word in a String

    This should work..

    DECLARE@tbl_Table TABLE

    (

    Column1 VARCHAR(100)

    )

    INSERT@tbl_Table

    SELECT'abbc cd ef' UNION ALL

    SELECT'abcdef' UNION ALL

    SELECT'adb ef cd' UNION ALL

    SELECT'ad cd eg'

    SELECT*

    FROM@tbl_Table AS t

    WHEREt.Column1 LIKE 'cd %'

    ORt.Column1 LIKE '% cd'

    ORt.Column1 LIKE '% cd %'

  • RE: SQL Query help

    We don't have any idea how your tables look like and what are the column names

    Can you provide us the DDL of the tables involved along with some sample data...

  • RE: problem with union

    You will have to use JOINS for the same

    I have used FULL OUTER JOIN in the code below( You can use INNER or LEFT OUTER as per your requirement)

    ; ...

  • RE: calculating period of time

    astrid 69000 (3/26/2013)


    yes i did, but i get confused, the "SELECT '2008-01-01 00:00:00.000', 3 UNION ALL" is not the one i need to add one by one manually?

    the query...

  • RE: calculating period of time

    Did you check the query I had posted 2 posts back?

    http://www.sqlservercentral.com/Forums/FindPost1435316.aspx

    This almost has what you require

    I had prepared that query based on the assumption of 5 days grouping which you...

  • RE: calculating period of time

    astrid 69000 (3/26/2013)


    but if i create the date table dont i have to add the dates manually?

    to calculate the first period i go

    select sum(Count) from #table where recordday >= '2008-01-01'...

Viewing 15 posts - 316 through 330 (of 898 total)