Forum Replies Created

Viewing 15 posts - 1,951 through 1,965 (of 3,543 total)

  • RE: Get database name for a particular user

    or

    declare @cmd varchar(300)

    declare @user varchar(30)

    set @user='loginname'

    select  @cmd = 'SELECT DISTINCT ''?''

    FROM master.dbo.syslogins l

    inner join [?].dbo.sysusers o ON o.sid = l.sid

    WHERE o.name = ''' + @user...

  • RE: Oracle ''''for x in ...'''' - is there an equivalent?

    No SQL Server equivalent but you could use

    DECLARE @sql varchar(8000)

    SET @sql = ''

    SELECT @sql = @sql + 'GRANT SELECT,INSERT,UPDATE,DELETE ON [' + TABLE_NAME + '] TO myuser;'

    FROM...

  • RE: Timeout Expired

    ConnectionTimeout is for timeout on connecting to SQL Server what you want is CommandTimeout, which is in seconds and has a default of 30.

    Set CommandTimeout to just above the longest query...

  • RE: Extracting binary data from an image field

    quoteTo satisfy my requirement, all I need is to get this result set stored via a cursor/local variable...
  • RE: Another easier way to concat string

    SELECT COALESCE([Last Name] + ', ' + [First Name], [Last Name], [First Name]) as [Name]

  • RE: how to count rows with Where

    SELECT (SELECT COUNT(*) FROM tb_hiter e2 WHERE e2.sn <= e.sn AND e2.na = 5940)

     AS rownumber, sn

     FROM tb_hiter e

     WHERE e.na = 5940

     ORDER BY sn

  • RE: Re : combinations function

    yes

    prob with my solution

    revised

    better to put options in permanent table

    CREATE TABLE [Priorities] ([ID] int, field char(50))...

  • RE: Inserting Line break in Store Procedure

    Try

    set @Body = 'Alert Mail – I (MIS) Progress Report to the Client First Reminder ' + CHAR(13) + CHAR(10)

    set @Body = @Body + CHAR(13) + CHAR(10) + 'ddfd'

  • RE: Re : combinations function

    CREATE FUNCTION dbo.udf__Test_Act_ind (@field_1 char(50),@field_2 char(50))

    RETURNS int

    AS

    BEGIN

      DECLARE @id int

      SET @id = 0

      DECLARE @combinations TABLE ([ID] int, field char(50))

      INSERT INTO...

  • RE: Selecting parts of a string

    Well, if we are playing then

    SELECT

    REVERSE(ISNULL(PARSENAME(REVERSE(REPLACE(FullName,' ','.')),1),'')),

    REVERSE(ISNULL(PARSENAME(REVERSE(REPLACE(FullName,' ','.')),2),'')),

    REVERSE(ISNULL(PARSENAME(REVERSE(REPLACE(FullName,' ','.')),3),''))

    FROM @FullName

  • RE: Complex function

    Notwithstanding the above

    CREATE FUNCTION dbo.udf_itinerary (@TicketID int, @BookingNo int)

    RETURNS varchar(8000)

    AS

    BEGIN

      DECLARE @itinerary varchar(8000)

      SET @itinerary = ''

      SELECT @itinerary = @itinerary + i.[From] +...

  • RE: Date format

    Add Language=x to the connection string where x is the sql language e.g.

    Italian is dd/mm/yyyy

    English is mm/dd/yyyy

    British English is dd/mm/yyyy

  • RE: Date format

    Check the language for the login and for the server (Default Language) as this affects the way dates are converted.

    If possible use yyyymmdd format or SET DATEFORMAT as already mentioned.

  • RE: Retuning Fomated number from a query

    SELECT

    REPLACE(CONVERT(varchar,CAST(ColA as money),1),'.00',''),

    REPLACE(CONVERT(varchar,CAST(ColB as money),1),'.00',''),

    REPLACE(CONVERT(varchar,CAST(ColC as money),1),'.00',''),

    CONVERT(varchar,CAST(ROUND(ColD,2,1) as money),1)

    FROM [TableName]

    Beware of rounding

    SELECT CONVERT(varchar,CAST(1.6075 as money),1)

    Result: 1.61

    SELECT CONVERT(varchar,CAST(ROUND(1.6075,2,1) as money),1)

    Result: 1.60

  • RE: Formatting Output

    Beware of rounding, ie

    DECLARE @number numeric(9,5)

    SET @number = 60.99999

    SELECT @number,CAST(@number AS numeric(6, 2))

    result

    60.99999 61.00

    SELECT @number,CAST(ROUND(@number,2,1) AS numeric(6, 2))

    result

    60.99999 60.99

Viewing 15 posts - 1,951 through 1,965 (of 3,543 total)