Viewing 15 posts - 1,066 through 1,080 (of 1,491 total)
SET ANSI_NULLS, QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION dbo.GetLocationDescription
(
@location_id int
)
RETURNS varchar(8000)
AS
BEGIN
    DECLARE @result varchar(8000)
        ,@Level int
    SELECT @result = ''
        ,@Level = 1
    DECLARE @cte TABLE
    (
        HLevel int NOT NULL
        ,Parent int NOT NULL
        ,[Description] varchar(255) NOT...
September 23, 2008 at 3:05 am
SET ANSI_NULLS, QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION dbo.GetLocationDescription
(
    @location_id int
)
RETURNS varchar(8000)
AS
BEGIN
    DECLARE @result varchar(8000)
    SET @result = ''
   WITH cte (HLevel, Parent, [Description])
    AS
    (
        SELECT 1 AS HLevel, T1.Parent, T1.[Description]
        FROM dbo.Location T1
        WHERE T1.location_id = @location_id
        UNION ALL
        SELECT C2.HLevel +...
September 23, 2008 at 2:31 am
This should get you started:
-- *** Test Data ***
CREATE TABLE #t
(
    InvNO int NOT NULL
    ,AccNo int NOT NULL
    ,TR_Age int NOT NULL
    ,Pay_Age int NOT NULL
    ,Amt int NOT NULL
    ,Pay_Amt int NOT NULL
    ,Run_Bal int...
September 11, 2008 at 9:26 am
It depends on the order of the tables. I prefer to think of the * being on the side where all the rows are returned.
--eg
SELECT *
FROM TableA A
    LEFT JOIN TableB...
September 8, 2008 at 5:19 am
The 'N' just means a nchar constant as opposed to a char constant.
September 1, 2008 at 6:21 am
You will need to cast to a float first.
SELECT CAST(CAST(N'2.00701E+16' AS float) AS bigint)
September 1, 2008 at 4:54 am
Your outer joins are effectively being converted to inner joins by the subsequent inner joins.
The joins should be nested so that the FROM clause looks something like:
FROM
    copay...
August 29, 2008 at 3:44 am
DELETE D
FROM
(
    SELECT
        ROW_NUMBER() OVER (PARTITION BY RefNoColumn, RowNoColumn ORDER BY RefNoColumn) AS RowID
    FROM YourTable
) D
WHERE RowID > 1
August 28, 2008 at 10:02 am
I use the following code to do some rough validation when importing email addresses.
SELECT EMail
FROM
(
    SELECT
        EMail
        ,CHARINDEX('.', REVERSE(EMail)) AS DotPos
        ,CHARINDEX('@', REVERSE(EMail)) AS AtPos
        ,CHARINDEX('@', EMail) AS AtPosStart
        ,REVERSE(LEFT(REVERSE(EMail), CHARINDEX('@', REVERSE(EMail)) - 1)) AS DomainName
        ,REVERSE(SUBSTRING(REVERSE(EMail),...
August 28, 2008 at 9:03 am
There is no need for a cursor, try something like:
-- *** Test Data ***
DECLARE @t TABLE
(
    iTableFieldId int NOT NULL
    ,iMenuId int NULL
    ,vFieldsName varchar(100) NULL
    ,iDataTypeName varchar(50) NULL
    ,iFieldLength int NULL
    ,bIsPrimary bit NULL
    ,bIsIdentity bit...
August 28, 2008 at 5:46 am
Rajan John (8/27/2008)
August 27, 2008 at 5:36 am
You could try a stored proc with two OUTPUT parameters.
August 22, 2008 at 10:45 am
I suspect the NOT EXISTS sub-query uses a view which contains at least one JOIN. This is not a good idea as JOINs in sub-queries tend to use NESTED LOOPS...
August 22, 2008 at 3:04 am
I think Jack meant something like:
UPDATE T1
SET Col1 = T2.Col1
    ,Col2 = T2.Col2
FROM Tab1 T1
    JOIN Tab2 T2
        ON T1.Col3 = T2.Col3
            AND T1.Col4 = T2.Col4
    JOIN
    (
        SELECT C.Col3, C.Col4, MAX(C.Col1) AS Col1
        FROM Tab2 C
        GROUP BY...
August 21, 2008 at 7:51 am
Viewing 15 posts - 1,066 through 1,080 (of 1,491 total)