Forum Replies Created

Viewing 15 posts - 1,726 through 1,740 (of 3,544 total)

  • RE: Grouping issue

    Some table defs, sample data and actual required results would be helpful

    But I consulted my Oiuja board  and.....

    SELECT [Category],[ProductName],[CompanyName]

    FROM

    (SELECT 1 AS [Category],p.[ProductName],p.[CompanyID]

    FROM [Product] p...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Tracking database growth

    Search the script section on this site, for example

    http://www.sqlservercentral.com/scripts/viewscript.asp?scriptid=1789

    I use this

    set nocount on

    /*

    Create the temp tables to hold the results of DBCC

    commands until the information is entered into

    DatabaseSpaceUsage

    */

    CREATE TABLE...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: TSQL Help

    LEFT([name],LEN([name])-CHARINDEX(' ',REVERSE([name]),PATINDEX('%[0-9]%',REVERSE([name])))+1) AS [name],

    RIGHT([name],CHARINDEX(' ',REVERSE([name]),PATINDEX('%[0-9]%',REVERSE([name])))-1) AS [name]

    may give you better results overall but I think you need to profile the data to see if there is any definate...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: TSQL Help

    You will get the error if the column does not contain a number preceeded by a space

    if so try this

    LEFT([name],PATINDEX('% [0-9]%',[name]+' 1')-1) AS [name],

    SUBSTRING([name],PATINDEX('% [0-9]%',[name]+' 1')+1,255) AS [version]

    Note the spaces...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: TSQL Help

    quote...highlight that space in red ...

     

    didn't think of that

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: TSQL Help

    Ooops! Sorry about that

     

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Check Constraint to enforce a pattern within data

    [CustomerID] LIKE '[A-Z][a-z][a-z][0-9]'

    AND ASCII(SUBSTRING([CustomerID],1,1)) = ASCII(UPPER(SUBSTRING([CustomerID],1,1)))

    AND ASCII(SUBSTRING([CustomerID],2,1)) = ASCII(LOWER(SUBSTRING([CustomerID],2,1)))

    AND ASCII(SUBSTRING([CustomerID],3,1)) = ASCII(LOWER(SUBSTRING([CustomerID],3,1)))

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: TSQL Help

    or use

    RTRIM(LEFT([column],PATINDEX('% [0-9]%',[column])-1)) AS [name]

    SUBSTRING([column],PATINDEX('% [0-9]%',[column]),255) AS [version]

    if you want to include a space before the number in case the name portion contains numbers

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: TSQL Help

    RTRIM(LEFT([column],PATINDEX('%[0-9]%',[column])-1)) AS [name]

    SUBSTRING([column],PATINDEX('%[0-9]%',[column]),255) AS [version]

    Is it possible for the string not to have a number?

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: a paradox

    A FOREIGN KEY can be null if taken in isolation

    A column can be NULL providing ALL the CONSTRAINTS applied to it allow it

    So

    A column that has a PRIMARY KEY...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Preventing doubling up of database

    quotewhen this column is specified as NOT FOR REPLICATION does that make this column a non clustered primary...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Preventing doubling up of database

    Setting a column to be an IDENTITY column will not make it a primary key. The primary key of a table is for you to decide. Making an IDENTITY column...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Preventing doubling up of database

    Yes, use an INSTEAD OF trigger

    CREATE TRIGGER [triggername] on

    INSTEAD OF INSERT

    AS

    BEGIN

        INSERT INTO ([column1],[column2])

        SELECT a.[column1],a.[column2]

        FROM [inserted] a

        LEFT OUTER...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Preventing doubling up of database

    1.

    ALTER TABLE ADD CONSTRAINT [constraintname] UNIQUE NONCLUSTERED ([column1],[column2])

    Look up 'constraints, UNIQUE' in Books Online (BOL)

    2.

    INSERT INTO ([column1],[column2])

    SELECT a.[column1],a.[column2]

    FROM [anothertable] a

    LEFT OUTER JOIN b

    ON...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Return all rows for todays date, and yesterday.

    Good catch Vladan

    Obvious when someone shows you how

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 15 posts - 1,726 through 1,740 (of 3,544 total)