Forum Replies Created

Viewing 15 posts - 2,551 through 2,565 (of 3,543 total)

  • RE: Copy Content from one table to other

    SELECT *

    INTO tableone

    FROM tablezero

    NOTE

    1. Select into/Bulk copy option must be set for database

    2. Primary Keys and Indexes will not be created for new table

    Alternatively

    CREATE TABLE tableone (col1,...

  • RE: Conversion of Hexadecimal Value To String - Most Urgent

    Not that I know of but you could write one like this

    CREATE  FUNCTION fn_hextovarchar

        (@input varchar(8000), @startoffset int = 1)

    RETURNS varchar(4000)

    AS

    BEGIN

      DECLARE @hex char(16),@output varchar(4000),@ptr int,@val int

      SET @hex...

  • RE: Devide by zero

    Divide by zero always returns null, the combination of ANSI_WARNINGS, ARITHABORT and ARITHIGNORE determines whether an error is produced or at what level the abort takes place (see BOL)

    So

    SET ANSI_WARNINGS OFF

    SET...

  • RE: Question about bulk insert

    Use a FormatFile to specify the order and type of input data and in which columns to place the data. Note that any column not specified must be nullable.

    BOL has...

  • RE: Forcing the workflow...

    In ExecuteSQL task, RAISERROR will cause the 'On Failure' workflow to trigger. eg

    IF NOT EXISTS (SELECT 1 FROM [sometable] WHERE [sometest])

    RAISERROR 'Record Does Not Exist',16,1

     

  • RE: Return counter in SELECT statement

    If the data is sorted on a column with unique values then you can do the following (uses pubs for example)

    select (select count(*)

      from pubs.dbo.stores s2

      where s2.stor_id...

  • RE: Returning output parameters from stored procedures

    Increase the size of @Courses. It must be large enough to hold all the database names (including a comma) plus the final comma.

    This is how I do .NET

    Public...

  • RE: Returning output parameters from stored procedures

    Try this

    alter procedure sp_GetUserValidation

    (

    @UserName varchar(50),

    @Courses varchar(50),

    @Return varchar(150) OUTPUT

    )

    AS

    SET NOCOUNT ON

    DECLARE @CourseName varchar(100), @UserValArray varchar(200), @Pos int

    DECLARE @sql nvarchar(500)

    DECLARE @Result char(1)

    SET @Return = ''

    SET @Courses = LTRIM(RTRIM(@Courses))

    IF @Courses = '' RETURN

    SET...

  • RE: Wierd Issue

    Yes I would be interested as well. The OR method is the way I do it, the ISNULL I got from other threads on this site and seemed a simpler neater...

  • RE: Updating multiple referance column data seperated by comma.

    If you have SQL2000, create a function

    CREATE Function dbo.fn_table1 (@col1 int)

    RETURNS varchar(1000)

    AS

    BEGIN

    DECLARE @result varchar(1000)

    SELECT @result = COALESCE(@result + ', ','') + CAST(NewCol1 as varchar)

    FROM...

  • RE: Wierd Issue

    where col1 = isnull(@p1,col1)

    and col2 = isnull(@p2,col2)

    and col3 = isnull(@p3,col3)

    But beware this will invoke a table or index scan.

  • RE: Updating Table with values from another table ?

    UPDATE p

    SET p.EmployeeNo = i.EmployeeNo

    FROM [primary] p

    INNER JOIN [import] i

    ON i.LastName = p.LastName

    AND i.Initial = LEFT(p.FirstName,1)

    WHERE p.EmployeeNo IS NULL

    BUT BEWARE! This will...

  • RE: Fuzzy logic matching routine problem

    Firstly I would remove the subqueries from the while statements and do them once at the beginning, ie

    declare @maxdataid int, @maxruleid int

    select @maxdataid = isnull(max([id]),0) from newdata

    select @maxruleid = isnull(max([id]),0)...

  • RE: Fuzzy logic matching routine problem

    Created on the fly no testing

    Probable poor performance

    Assumes complete sql (including rules/test) less than 4000 bytes

    CREATE TABLE #tests (rowid int IDENTITY(1,1),test nvarchar(100))

    INSERT INTO #tests (test) values ('where rule1')

    INSERT...

  • RE: variable column alias

    SET DATEFIRST 7  --Set First Day of Week to Sunday

    SELECT SUM(CASE WHEN DATEPART(weekday,[date]) = 1 THEN [column] ELSE 0 END) AS 'Sun',

     SUM(CASE WHEN DATEPART(weekday,[date]) = 2 THEN [column] ELSE...

Viewing 15 posts - 2,551 through 2,565 (of 3,543 total)