Forum Replies Created

Viewing 15 posts - 1,681 through 1,695 (of 2,007 total)

  • RE: Select Records For Any Month

    --First, lets build some test data

    DECLARE @table AS TABLE (mydate DATETIME)

    ;WITH testdata AS (

    SELECT CAST('2011-01-01' AS DATETIME) datevalue, 1 AS counting

    ...

  • RE: Get list of tables used in a stored procedure

    I realise this is old, but I found it useful today.

    I modified the code: -

    ;WITH stored_procedures AS (

    SELECT

    o.name AS proc_name, oo.name AS table_name,

    ROW_NUMBER() OVER(partition by o.name,oo.name ORDER BY o.name,oo.name)...

  • RE: Subsequent rows compare

    Assuming davidandrews13 has guessed correctly about how you determine the "subsequent" row, then his idea is sound. You can run the update statement straight from the CTE - e.g.

    ;WITH...

  • RE: How to Ignore the records based on their addition

    Can you provide readily consumable test data, please?

    e.g., from your first post: -

    DECLARE @table AS TABLE

    (id INT, [type] VARCHAR(10), amt INT)

    INSERT INTO @table

    SELECT 101, 'Cash', 100

    UNION ALL SELECT 101, 'Credit',...

  • RE: Date query

    SELECT *

    FROM dbo.tvwcontractview

    WHERE businessunit = 'Property_DATA_LIBRARY'

    AND book = 'Property - Live'

    AND [Type] =...

  • RE: Are the posted questions getting worse?

    Craig Farrell (4/14/2011)


    Alright, there's any number of things to take my article apart for, half of it's an opinion... but there's vs. there are?

    I'm going to assume I'm just too...

  • RE: Problem with query???

    Look up Pivot.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns[/url]

    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs[/url]

    If you want more help, please provide readily consumable...

  • RE: Work Experience - What work would you give someone?

    Please bear in mind that when I said "work experience lad", I meant a 15 year old school kid. In the UK that means the extent that school had taught...

  • RE: Help a T-SQL Newbie

    And just in case you intend to do all of your date formatting in SQL (it's a presentation layer task imo, so should be done in the front end code...

  • RE: Help a T-SQL Newbie

    WITH weekdays

    AS (SELECT CONVERT(DATETIME, Dateadd(dd, -Datepart(dw, Getdate()), Getdate())+1) AS startofweek,

    ...

  • RE: Issue with max value in an expression

    karen.blake (3/31/2011)


    Ahhh skcadavre yes it is me, back again. I swear I just cannot get enough of this place and SQL 😛

    And as per usual thank you so much it...

  • RE: Issue with max value in an expression

    karen.blake (3/30/2011)


    Hi Daniel,

    Thanks for replying. I did wonder if this might be the problem so I took the floor out but a)this hasn't changed the value and b) my problem...

  • RE: Work Experience - What work would you give someone?

    In case someone else ends up in a similar position, here is what I've decided.

    I'm going to have him design and write a very simple inventory system, allowing us to...

  • RE: how to trim only the leading zeros in the tsql query

    An alternative would be to cast as a BIGINT.

    e.g.

    DECLARE @phonenumber VARCHAR(12), @areacode VARCHAR(5), @countrycode VARCHAR(2)

    SET @phonenumber = '367894'

    SET @areacode = '04252'

    SET @countrycode = '61'

    SELECT

    CAST(CAST(REPLACE(REPLACE(LTRIM(RTRIM(@countrycode)),'-',''),' ','') AS BIGINT) AS VARCHAR(2))...

  • RE: IN Clause in SQL Query

    OK. It'd be an ambiguous column error if you were to join these hypothetical tables on the IDs.

Viewing 15 posts - 1,681 through 1,695 (of 2,007 total)