Forum Replies Created

Viewing 15 posts - 16 through 30 (of 139 total)

  • RE: help sytax distinct union into

    INTO : only for first select

    UNION : If distinct is needed, do not use UNION ALL, but use UNION

     

    Correct syntax is :

    SELECT DISTINCT Column1 AS Name

    INTO            New_Table

    FROM         Old_Table

    UNION

    SELECT DISTINCT Column2 AS...

  • RE: Data Manipulation - creating new tables

    your demand is not very clear ( what is first? ), but this script could be a start :

    set nocount on

    go

    use tempdb

    go

    if object_id('ori') is not null drop table ori

    if object_id('TableA')...

  • RE: conversion datetime

    When you need to convert back to datetime, you should also specify the style :

    declare @d1 datetime

    set @d1 = getdate()

    select dateASchar       =                  convert(varchar(10),@d1,103)

    go

    declare @d1 datetime

    set @d1...

  • RE: sql statement

    Try this ...

    -- clean up : DO NOT RUN ON PRODUCTION DB : tables will be dropped !!

    if db_name() = 'tempdb'

    begin

     declare @object_id int

     set @object_id =  object_id('dbo.fn_colsplit')

     if @object_id is...

  • RE: List all days between start and end dates

    The best way to do this is using a table with positive numbers. This way you can avoid using cursors, and even create a view.

    This sql script ( test it...

  • RE: Passing GetDate() as a parameter to a UDF datetime parameter

    To avoid the problem, I use my function dbo.fn_getdate(). This function can be used in other functions:

    script ( create it in master, and call fn_getdate as master.dbo.fn_getdate() ) :

    create table...

  • RE: Saving XML data using stored procedure

    For this to work, your xml should be like :

    <root>

    <screens>

    <ScreenId>1</ScreenId><RoleId>1</RoleId>

    </screens>

    <screens>

    <ScreenId>3</ScreenId><RoleId>1</RoleId>

    </screens>

    <screens>

    <ScreenId>7</ScreenId><RoleId>1</RoleId>

    </screens>

    <screens>

    <ScreenId>8</ScreenId><RoleId>1</RoleId>

    </screens>

    </root>

  • RE: Simplify the Creation of XML from SQL Server Data

    I couldn't get it either ...

  • RE: Simplify the Creation of XML from SQL Server Data

    Great article.

    I would really like to see how this is implemented, but could not find the download ?

  • RE: Text to sp_xml_preparedocument

    You can read the xml into a text variable. But you can not declare a text variable in a stored procedure. You can have a parameter of type text, so...

  • RE: Can UDF accept Optional parameter

    For a function, you have to give all the parameters. You can use default to specify you want to use the default value : select @a =dbo.ufn_test(DEFAULT)

    Bert

  • RE: Find All Records With A Lowercase Letter

    I tried that before proposing upper(). I tried it using an english alphabet ... and it does not work with '%[a-z]%'. I do not understand why ...

     

    Bert

  • RE: Find All Records With A Lowercase Letter

    You can also use

    where somecode != upper(somecode) COLLATE SQL_Latin1_General_CP1_CS_AS

     

  • RE: temporary table and index creation?

    It depends of the numer of data to be inserted in the table. If you create the clustered index first, the server has to find first where to insert the...

  • RE: Very large tables w/o PKs, clustered indexes

    If you want to increase performance, creating an index that will never be used makes no sense.

    I would replace one of the non clustered indexes by a clustered index. But again,...

Viewing 15 posts - 16 through 30 (of 139 total)