Forum Replies Created

Viewing 15 posts - 2,776 through 2,790 (of 8,731 total)

  • RE: do table types support default constraints?

    What problem are you facing?

    This works:

    CREATE TYPE SomeTableType AS TABLE

    ( SomeID int IDENTITY(1,1)

    , SomeValue Varchar(10)

    , SomeDate datetime DEFAULT GETDATE());

    GO

    DECLARE @test-2 AS SomeTableType;

    INSERT INTO @test-2 (SomeValue) VALUES ('ABC');

    SELECT * FROM...

  • RE: MSSQL 2016 express edition

    If you'll use it to learn, practice or any non-production related functionality, I would suggest that you try the developer edition. You can get it here: https://www.visualstudio.com/en-us/products/visual-studio-dev-essentials-vs.aspx

  • RE: Case When statement returning multiple rows

    Maybe you need to aggregate?

    SELECT

    CALL_1,

    MAX(CASE WHEN RESP.OUTCOME1 = OUT.OUTCOME THEN OUT.SIMPLIFIED END) AS OUTCOME_1,

    CALL_2,

    MAX(CASE...

  • RE: Pivot table queries

    Dynamic pivoting is not the easiest thing, but once you understand how it works, it's really simple.

    The first part is to understand how to do it in a static way....

  • RE: Query not executing dynamic way

    I prefer to use QUOTENAME which will escape quotes and brackets correctly, as well as handle weird names.

    DECLARE

    @dbname sysname,

    @objname sysname,

    ...

  • RE: Convert to CSV

    ChrisM@Work (6/2/2016)


    There are several ways to do this, most of them are compared here.

    I would suggest that you use the XML PATH option (unless you already use CLR). If you...

  • RE: Beginning and End of Year, Month, Etc.

    Luis Cazares (6/1/2016)


    Here are four out of six formulas. You need to understand those, then create the 2 missing ones. Avoid scalar functions and use inline table functions or use...

  • RE: Beginning and End of Year, Month, Etc.

    Here are four out of six formulas. You need to understand those, then create the 2 missing ones. Avoid scalar functions and use inline table functions or use the scalar...

  • RE: T Sql Query

    This is a corrected script for some sample data.

    It doesn't fix any logic, just fixed the sample data script and changed formulas for the dates to shorter versions.

    CREATE TABLE [dbo].[PNS_Sect_6_SiteSEPStatusSnapshot](

    [ID]...

  • RE: Are the posted questions getting worse?

    Grant Fritchey (5/31/2016)


    Because SQL Fertilization needs to become something we all talk about. It's important. Don't you understand how SQL Fertilization works?

    I have to say a lot of people have...

  • RE: Topic has disappeared

    DamianC (5/31/2016)


    Anybody know why topics periodically disappear

    I had an open topic (1790418)

    It seems to have disappeared

    I'm still in the process of trying to resolve the issue and can no longer...

  • RE: Are the posted questions getting worse?

    Is SQL Fertilization the reason we have so much code and practices that look like feces?

  • RE: Column to Rows Sql help

    GSquared (5/31/2016)


    Any reason to not use UNPIVOT for this?

    Confusing syntax, in my opinion. But that's a personal preference.

  • RE: SQL Query - View

    Something like this?

    DECLARE @SQL varchar(max);

    SET @SQL = (SELECT Query + CHAR(10) FROM #Temp FOR XML PATH(''), TYPE).value('./text()[1]', 'varchar(max)');

    EXEC( @SQL);

    Or this:

    DECLARE @sql varchar(max)...

  • RE: Column to Rows Sql help

    Avoid using UNION when you're not trying to remove duplicates. Use UNION ALL to include all items and avoid unnecessary sorts.

    I would use a table valued constructor instead.

    SELECT ...

Viewing 15 posts - 2,776 through 2,790 (of 8,731 total)