Forum Replies Created

Viewing 15 posts - 31 through 45 (of 82 total)

  • RE: insert the value to the temp table

    try this

    SET @sql = @sql + 'AND CTDate <= CAST('''+@todate+''' AS DATETIME))'

  • RE: insert the value to the temp table

    Use Dynamic Or Static

    Please make sure you use syntax

    EXEC (@SQL) instead if EXEC @sql

     

    Ram

     

  • RE: round up the result int to next whole numberr

    Try this

    DECLARE @A INT

    DECLARE @b-2 INT

    SELECT  @A = 11267

    SELECT @B = 500

    SELECT CASE @A%@B WHEN 0 THEN @A/@B ELSE (@A/@B)+1 END

      

     

  • RE: help on parseing names

    Did you try like below

    SELECT  LEFT((RTRIM(ENAME)),CHARINDEX(',',(RTRIM(ENAME)))-1) LastName,

     PARSENAME(REPLACE(STUFF((RTRIM(ENAME)),1,CHARINDEX(',',(RTRIM(ENAME)))+1,''),' ','.'),2) FirstName,

     PARSENAME(REPLACE(STUFF((RTRIM(ENAME)),1,CHARINDEX(',',(RTRIM(ENAME)))+1,''),' ','.'),1) MiddleName

    FROM TFILP

    Ram

     

     

     

  • RE: T-SQL returning 1 record

    Try this out (If you have more columns)

    SELECT A.*

    FROM tblXYZ AS A

     INNER JOIN  (

       SELECT  ColumnA,MIN(ColumnB) AS ColumnB

       FROM  tblXYZ

       GROUP BY ColumnA

      &nbsp AS B

      ON  A.ColumnA = B.ColumnA

      AND A.ColumnB =...

  • RE: T-SQL returning 1 record

    SEELCT ColumnA,MIN(ColumnB) OR MAX(ColumnB)

    FROM tblXYZ

    GROUP BY ColumnA

    Ram

  • RE: Data conversion error

    Try using FLOAT

    SELECT CONVERT(FLOAT,'689.99')

  • RE: help me on setting auto number property for a column

    CREATE TABLE xyz

    (TABLE_NUM INT PRIMARY KEY,

    VOICE INT IDENTITY(1,1))

    -Ram

     

     

  • RE: How to assign a user the privilege to execute all stored procedures only?

    USE [DBName]

    GO

    SELECT 'GRANT ALL ON ['+Name+'] TO [User]' -- Change UserName here

    FROM SysObjects

    WHERE XType = 'P'

    get the o/p query and run in QA.

    Ram

     

     

  • RE: update or insert record

    Here you go

    BEGIN

     SET NOCOUNT ON

     DECLARE @tblTarget TABLE

      (Book  VARCHAR(256),

      Price  INT,

      DateUpdated DATETIME)

     DECLARE @tblSource TABLE

      (Book  VARCHAR(256),

      Price  INT)

     INSERT INTO @tblTarget VALUES('A',10,NULL)

     INSERT INTO @tblTarget VALUES('B',5,NULL)

     INSERT INTO @tblSource VALUES('A',10)

     INSERT INTO @tblSource VALUES('B',15)

     INSERT INTO @tblSource VALUES('C',8)

     INSERT INTO @tblTarget (Book,Price,DateUpdated)

     SELECT DISTINCT Book,Price,GETDATE()

     FROM @tblSource AS Source

     WHERE NOT EXISTS

      (

      SELECT 1

      FROM @tblTarget AS Target

      WHERE LTRIM(RTRIM(Source.Book)) = LTRIM(RTRIM(Target.Book))

    --  AND ISNULL(Source.Price,-999) = ISNULL(Target.Price,-999)

     &nbsp

  • RE: TSQL Question

    Try this out

    SELECT [Dept],

     [Job Code],

     SUM(CASE WHEN [Charge Code] IN ('NPO','REG E','HOL','VAC') THEN [Hrs Worked] ELSE 0 END) AS RegHours,

     SUM(CASE WHEN [Charge Code] IN ('NPO','REG E','HOL','VAC') THEN [Dollars] ELSE 0 END) AS...

  • RE: Time Stamp Error

    try this out

    SELECT CONVERT(CHAR(30),GETDATE(),109) AS TimeStamp

  • RE: Ridiculously STRANGE query - help please?

    Try UNION ALL instead UNION.....

  • RE: grouping by character data

    Try this out (You can modify this T-SQL according to your need)

    DECLARE @tbl TABLE

     (RowId  VARCHAR(20),

     RValue  VARCHAR(30),

     Lineage  VARCHAR(3000) DEFAULT '')

     

    INSERT INTO @tbl(RowId,RValue)

    SELECT 1,'1A' UNION SELECT 1,'1B' UNION SELECT 1,'1C' UNION SELECT 1,'1D' UNION SELECT 2,'2A' UNION SELECT 2,'2B'...

  • RE: Need Help with Query

    or this

    SELECT Owner,

     MIN(PropertyId) AS MinId,

     MAX(PropertyId) AS MaxId

    FROM #Table

    GROUP BY Owner

     

Viewing 15 posts - 31 through 45 (of 82 total)