Forum Replies Created

Viewing 15 posts - 421 through 435 (of 516 total)

  • RE: Foreign Key question

    Kingston Dhasian (7/27/2012)


    If you have a UNIQUE KEY constraint on the column Col1 of table T1, then its possible to define a FOREIGN KEY as you have mentioned

    But, if the...

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • RE: next day function

    Step 1 : adds one day to current datetime

    SELECT GETDATE()+1 AS NextDay

    Step 2 : If only date is required

    SELECT CONVERT(DATE,GETDATE()+1) AS NextDay

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • RE: Determine ANSI_PADDING status in TSQL

    Lynn Pettis (7/27/2012)


    Lokesh Vij (7/27/2012)


    For checking ANSI_PADDING on columns:

    SELECT name column_name,

    CASE is_ansi_padded

    ...

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • RE: Determine ANSI_PADDING status in TSQL

    To further add (SQL Server 2012 BOL):

    In a future version of Microsoft SQL Server ANSI_PADDING will always be ON and any applications that explicitly set the option to OFF will...

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • RE: Determine ANSI_PADDING status in TSQL

    For checking ANSI_PADDING on columns:

    SELECT name column_name,

    CASE is_ansi_padded

    ...

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • RE: Tempdb Que

    Temp Objects are always tied to the current session. As soon as the session is closed, all the temp objects created for that session are destroyed from Temp DB

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • RE: SQL Server - Identity

    corbincreativecomputing (7/26/2012)


    Identity (or AutoNumber) is a column that automatically generates numeric values. A start and increment value can be set, but most DBAs leave these at 1. A GUID column...

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • RE: Why only final row set to variable on CASE select?

    +1

    Kartik, even my query gives the same output as that of Chris 🙂

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • RE: Why only final row set to variable on CASE select?

    ChrisM@Work (7/26/2012)


    neil-560592 (7/26/2012)


    ...

    Why is it missing the first two values (USD and EUR)?

    Thanks

    Well I'm stumped on this one. The CASE expression is a red herring - it's irrelevant. What's significant...

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • RE: Rename column

    Miles Neale (7/25/2012)


    Lokesh - I looked at this for a few minutes and come to this:

    1. The update is a delete and add, both could generate a message in a...

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • RE: How merge the result set of two select statement into two columns in single result set?

    Kindly post some sample data and expected result. I will get back to you

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • RE: Not able to insert a particular value

    deepzzzz (7/26/2012)


    Hi,

    Please find the below query

    INSERT INTO tbl_employee (EmpNo,CompanyID,MngrID,DateOfFiled,DateOfClosed,DateOfCreation

    ,LastModified,Active,flag)

    VALUES(

    '2011-1508' ,89827,null,null,null,GETDATE(),GETDATE(),1,'C')

    In the table, column 'Active' is of type int

    I...

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • RE: How merge the result set of two select statement into two columns in single result set?

    Like this:

    Select col1.column_name,col2.column_name

    FROM

    (SELECT row_number() over (order by c.name) rnum,

    c.name AS column_name

    FROM AADHAR_KYR.sys.tables AS t

    INNER JOIN AADHAR_KYR.sys.columns c ON t.OBJECT_ID = c.OBJECT_ID

    where t.name='EID_UID_MAPPING' ) as [Col1],

    (SELECT row_number()...

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • RE: cumulative percentage

    Are you looking for something like this:

    CREATE TABLE [productsalesRanked](

    [rank1] [bigint] NULL,

    [unitssum] [float] NULL,

    [nvarchar](5) NULL,

    [ProductSalesPopularityID] [int] NOT NULL,

    [categoryid] [int] NOT NULL,

    [ProductID] [int] NOT NULL,

    [UnitsSold] [int] NULL

    );

    INSERT INTO productsalesranked VALUES

    (1,13.5509396636993,'A',58,270789,1431415,274),

    (2,13.1058358061325,'B',58,270789,2975838,265),

    (3,13.0069238377844,'A',58,270789,1431410,263),

    (4,12.6112759643917,'A',58,270789,1445296,255),

    (5,12.6112759643917,'A',58,270789,2960786,255),

    (6,7.81404549950544,'C',58,270789,2975847,158),

    (7,5.98417408506429,'C',58,270789,1431417,121),

    (8,4.50049455984174,'D',58,270789,1708294,91),

    (9,3.41246290801187,'B',58,270789,1431416,69),

    (10,2.67062314540059,'A',58,270789,2975840,54),

    (11,1.68150346191889,'D',58,270789,1445294,34),

    (12,1.53313550939664,NULL,58,270789,2207608,31),

    (13,1.38476755687438,'B',58,270789,1431418,28),

    (14,1.13748763600396,'B',58,270789,1445292,23),

    (15,0.939663699307616,'C',58,270789,1445297,19),

    (16,0.890207715133531,NULL,58,270789,2975839,18),

    (17,0.791295746785361,NULL,58,270789,2975844,16),

    (18,0.494559841740851,'D',58,270789,2207610,10),

    (19,0.494559841740851,'D',58,270789,1445295,10),

    (20,0.395647873392681,NULL,58,270789,3077856,8),

    (21,0.346191889218595,'C',58,270789,1708290,7),

    (22,0.29673590504451,NULL,58,270789,1445298,6),

    (23,0.0989119683481701,'D',58,270789,2975842,2),

    (24,0.0989119683481701,NULL,58,270789,2975846,2),

    (25,0.0494559841740851,NULL,58,270789,1431414,1),

    (26,0.0494559841740851,NULL,58,270789,2207609,1),

    (27,0.0494559841740851,'D',58,270789,1706287,1),

    (28,0.0494559841740851,NULL,58,270789,2975841,1),

    (29,-0.0494559841740851,'D',58,270789,2975843,-1),

    (1,17.6112412177986,'C',58,270795,1445199,376),

    (2,16.5339578454333,'A',58,270795,1445197,353),

    (3,7.40046838407494,'B',58,270795,1708203,158);

    SELECT p.ProductSalesPopularityID,

    p.categoryid,

    p.ProductID,

    UnitsSold,

    rank1,

    CAST(unitssum...

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • RE: Contained Databases

    anthony.green (7/26/2012)


    Damn, got 3 out of the 4, I thought mirroring wouldn't of been true as it is now a depreciated feature so, wouldn't of thought the two would co-exist.

    I...

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

Viewing 15 posts - 421 through 435 (of 516 total)