Forum Replies Created

Viewing 15 posts - 2,446 through 2,460 (of 3,957 total)

  • RE: database relationships

    ch.omkarreddy (11/21/2012)


    yeah planned about same one thanks but could you please provide me a query as i am a beginner in sql server

    You need to provide DDL and sample data...

  • RE: Parameterized dynamic SQL

    Would this work?

    DECLARE @DB VARCHAR(100) = 'MyDB'

    SELECT *

    FROM @DB.sys.check_constraints

    If not, why would it work in dynamic SQL?

    Obviously, you've found an approach that does work though.

  • RE: database relationships

    ch.omkarreddy (11/21/2012)


    if any insertions are done then the inserted data and modified id should be automatically generated in master table

    It can be done with a cross-schema trigger, but that is...

  • RE: MAX behavior difference with nvarchar and varchar column types

    Change the COLLATE for one of the columns.

    Try this:

    create table my_table(id1 nvarchar(10), id2 varchar(10))

    SELECT TABLE_NAME, COLUMN_NAME,CHARACTER_SET_NAME, COLLATION_NAME

    FROM information_schema.columns

    WHERE TABLE_NAME = 'my_table'

    insert into my_table VALUES ('-1','-1');

    insert into my_table VALUES ('1','1');

    SELECT MAX(id1...

  • RE: need help with a query

    Jeff Moden (11/21/2012)


    dwain.c (11/21/2012)


    Jeff Moden (11/21/2012)


    Oh man.... I can't remember if it was Lowell or Magoo or ??? but we've been through this problem before (couple of years ago?) and...

  • RE: Two Rows Returned as One for Reporting

    Jeff Moden (11/21/2012)


    And, look Ma! No WHILE loop!

    Nice Crosstab and Modulus, Dwain.

    Aw shucks, Master. T'weren't nuthin'!:blush:

  • RE: need help with a query

    Jeff Moden (11/21/2012)


    Oh man.... I can't remember if it was Lowell or Magoo or ??? but we've been through this problem before (couple of years ago?) and somebody posted some...

  • RE: switching address with Subtring & len funtion

    Jeff Moden (11/21/2012)


    I don't believe that COLLATE will help a STUFF (but I haven't tested it). Logically speaking, it should only help when string comparisons are being made.

    I didn't...

  • RE: Two Rows Returned as One for Reporting

    Call me weird or whatever but I don't think this is particularly messy at all using a simple cross tab query.

    First, Michael's set up data with a couple of additional...

  • RE: Input Validation

    Try it like this:

    DECLARE @Valid_PolicyId INT

    DECLARE @PolicyIdInput VARCHAR(100) = '222222222222222222222'

    DECLARE @PolicyID INT

    DECLARE @Err INT = 0

    --check if PolicyId inputed--

    IF ISNULL(@PolicyIdInput, '') = ''

    BEGIN

    RAISERROR ('Policy...

  • RE: need help with a query

    sapen (11/21/2012)


    Is this possible?

    Sure! Anything is possible in the SQLverse. Assuming of course that when you say "consecutive" the Date column controls this. Try the following:

    CREATE TABLE #Test(

    [Date]...

  • RE: SQL Query: Subtract data from consecutive rows uptil non zero value reached.

    How about something like this?

    ;WITH Amounts AS (

    SELECT CurrentLine, Amount, RowNumber, [Difference]=CAST(0 AS FLOAT)

    ,[Rows Subtracted]=CAST('N/A' AS VARCHAR(13))

    ...

  • RE: switching address with Subtring & len funtion

    Eugene Elutin (11/21/2012)


    Here we go!

    ...

    Actually, there is another aspect of using STUFF in Dwain's style - it does change collation of original string, which may not be appropriate sometimes.

    Eugene Elutin...

  • RE: switching address with Subtring & len funtion

    Eugene,

    If you're going to cast aspersions on my code with garbage data, I think you should first look to your own. Try this:

    select

    SUBSTRING(email, CHARINDEX('.', email)+1,CHARINDEX('@', email)-CHARINDEX('.', email)-1)

    ...

  • RE: switching address with Subtring & len funtion

    Eugene Elutin (11/21/2012)


    PRINT 'Dwain.C COLLATE + CROSS APPLY'

    SET STATISTICS TIME ON

    SELECT @Email=RIGHT(

    STUFF(a.email

    ...

    SELECT email...

Viewing 15 posts - 2,446 through 2,460 (of 3,957 total)