Forum Replies Created

Viewing 15 posts - 451 through 465 (of 596 total)

  • RE: UNION or CONCANTENATE - ?

    If the text columns contain text less than 8000 characters in length, you could convert to varchar, like this:

    UPDATE Contacts

       SET memo = CONVERT(varchar(8000), cct.TextTransfer) + ' ' + CONVERT(varchar(8000),...

  • RE: UNION or CONCANTENATE - ?

    Are all of the columns you are concatenating of type char or varchar? Numeric types will have to be converted (using CONVERT or CAST) to a character type.

    For example, if...

  • RE: Creating a user in QA with a default database

    To add a SQL Server login, refer to:

    sp_addlogin [ @loginame = ] 'login'

        [ , [ @passwd = ] 'password' ]

        [ , [ @defdb = ] 'database' ]

        [...

  • RE: Update Text

     

    I think you've made your code unnecessarily complex. It seems as though you should be able to set @txtToAdd with this query:

    SELECT @txtToAdd = 'Transfer Date: ' + udfv.fieldvalue 

      FROM UserDefinedFieldvalue...

  • RE: This should be a simple update statement (I think!)

    To correct your correlated subquery, you would do the following:

    UPDATE Objects

       SET SerialNumber =

               (SELECT SerialNumber

                  FROM temp1

                 WHERE temp1.un_id = objects.Un_ID 

               )

    This particular WHERE clause...

  • RE: how to add one second

    How about this:

    DECLARE @dt datetime

    SET @dt = '7/4/2004'

    SELECT DateDiff(s, @dt, GetDate())

  • RE: Tokenizing a String Using PARSENAME

    I'm sorry, I didn't intend to be unkind with my remarks. I was just trying to provide an alternative that works better for me.  Most code has limitations of some kind.

    Happy...

  • RE: how to add one second

    Frank is correct. The question was how to add 1 (second) to

    select datepart(second,Getdate())

    which returns an integer whose units are seconds. Thus,

    SELECT DatePart(s, Getdate()) + 1

    If the problem is how...

  • RE: Tokenizing a String Using PARSENAME

    I agree with Slawomir Mucha. Also, if the occurrence number provided exceeds the number of substrings, the last substring is returned. I prefer to return an empty string in those...

  • RE: Problem with xp_cmdshell - URGENT

    When you execute the batch from xp_cmdshell, the batch file is run in the security context of the SQL Server service login id.

    Another problem is that the H: drive mapping...

  • RE: Problem with xp_cmdshell - URGENT

    To output the results of a query with bcp, you need to fully qualify the table name in your query:

    bcp "Select * from TEST.dbo.users" queryout H:\TESTSHARE\Test.tb2 -c -S"MAHESH"  -T

    or

    bcp "Select...

  • RE: Formatting numbers (commas and decimal)

    I'm not sure if this will help, but here's a script I wrote, followed by a bunch of examples:

    DROP FUNCTION dbo.FormatDec

    GO

    CREATE FUNCTION dbo.FormatDec

    (

      @num decimal(38,4),

      @decPlaces int

    )

    RETURNS varchar(20)

    AS

    BEGIN

      DECLARE @cnum...

  • RE: Rounding to zero

    Another simple example:

    declare @a integer, @b-2 integer

    set @a = 10

    set @b-2 = 100

    select (0.0 + @a) / @b-2

  • RE: Parsing single and double quotes

    Steve meant to say "clear the checkbox" for set quoted identifier. When "set quoted identifier" is on, double quotes indicate column names. I always use single quotes for string constants...

  • RE: record lenght

    If you just want to sum the maximum lengths of all the column in a table, you could something like this:

    DECLARE @tableName varchar(128)

    SET @tableName = '<your table>'

    SELECT Sum(c.length) as MaxDataBytes

     ...

Viewing 15 posts - 451 through 465 (of 596 total)