Forum Replies Created

Viewing 15 posts - 1 through 15 (of 89 total)

  • RE: pulling data from end of column

    SELECT RIGHT(String,

    CASE WHEN CHARINDEX('ssalc',REVERSE(String))= 0

    THEN 0

    ELSE CHARINDEX('ssalc',REVERSE(String))+5

    END

    )

    FROM @tbl

  • RE: pulling data from end of column

    --Load the string in table varible

    DECLARE @tbl TABLE

    (

    String NVARCHAR(1000)

    )

    INSERT INTO @tbl

    SELECT 'Net asset value per share' AS ID

    UNION ALL SELECT 'Net Asset Value for Ignis Absolute Return Government Bond...

  • RE: pulling data from end of column

    ;with cte as

    (

    SELECT 'Net asset value per share' AS ID

    UNION ALL SELECT 'Net Asset Value for Ignis Absolute Return Government Bond Fund . Class A GBP'

    UNION ALL SELECT 'Total Outstanding...

  • RE: Dynamic sql giving en error

    I added the IF exist condition in the script

    DECLARE @DATABASENAME sysname;

    DECLARE @sql NVARCHAR(max);

    SET @DATABASENAME = 'SFM_QA03'

    SET @sql = N'SELECT '+'''IF NOT EXISTS (SELECT TOP 1 NULL FROM sys.synonyms a

    JOIN...

  • RE: In-Line Function to split string

    DECLARE @tblNumber TABLE

    (

    ID INT

    )

    INSERT INTO @tblNumber

    SELECT TOP 1000 ROW_NUMBER() OVER(ORDER BY S.Object_id) FROM sys.objects s,sys.objects si

    DECLARE @tbl TABLE

    (

    ID INT, [Value] NVARCHAR(1000)

    )

    INSERT INTO @tbl

    SELECT '13','Mitesh,Sohan,Oswal' UNION

    SELECT '14','Pune,Kalyan,Maharashtra' UNION

    SELECT '15','31,3110,311083' ...

  • RE: How to fetch count ?

    IF OBJECT_ID('tempdb..#temp')IS NOT NULL

    DROP TABLE #temp;

    CREATE TABLE #temp

    (

    ID INT,

    ID1 INT

    )

    INSERT INTO #temp

    SELECT 1,2

    UNION

    SELECT 2,1

    IF OBJECT_ID('tempdb..#temp2')IS NOT NULL

    DROP TABLE #temp2;

    CREATE TABLE #temp2

    (

    ID INT,

    ID1 INT

    )

    DECLARE @tbl TABLE

    (

    ID INT IDENTITY(1,1),

    Query NVARCHAR(1000)

    )

    INSERT INTO @tbl

    SELECT...

  • RE: SQL Query

    Hi,

    The Query execution is simmilar to below query

    select *,case when headofficeid = 0 then officeid else headofficeid end [FirstSort],case when headofficeid = 0 then 1 else 2 end [SecondSort]

    from offices...

  • RE: Need to un-pivot some columns, pivot one column

    SELECT [CampusID],Campus1,Campus2,[TermID],[Term],[StudentID],[Qualification],[Programme],status FROM

    (

    SELECT [CampusID],Campus,[TermID],[Term],[StudentID],[Qualification],[Programme],

    IIF(Repeat1stYEar = '1' , 'Repeat1stYEar',

    IIF([Repeat2ndYear] = '1' , 'Repeat2ndYear',

    IIF(Repeat3rdYEar = '1' , 'Repeat3rdYEar',

    IIF(NotReturn2ndYr = '1' , 'NotReturn2ndYr',

    IIF(NotReturn3rdYr = '1' , 'NotReturn3rdYr',

    IIF(NotReturn4thYr = '1' , 'NotReturn4thYr',NULL)))))) status

    FROM...

  • RE: Arrival and Depart location query help.

    ;with cte

    as

    (

    SELECT departcty ,arrivalcty ,departcty as Firstdepartcty, CAST(arrivalcty AS VARCHAR(6)) as Firstarrivalcty ,seqnum,tktamt,tktnum

    FROM #xy123 where seqnum = 1

    UNION ALL

    SELECT s.departcty ,s.arrivalcty , Firstdepartcty as Firstdepartcty,

    CASE...

  • RE: More than 1 alphanumeric chars in a string

    DECLARE @tbl TABLE

    (

    ID INT IDENTITY(1,1),

    Char1 NVARCHAR(100)

    )

    INSERT INTO @tbl

    select 'ABC x.yz'

    UNION

    select 'A.BC X.*YZ'

    UNION

    select 'A.BC *X.YZ'

    DECLARE @tblNumber TABLE

    (

    Number INT

    )

    INSERT INTO @tblNumber

    SELECT TOP 1000 ROW_NUMBER() OVER(ORDER BY S.Object_id )

    from sys.objects s,sys.objects s1

    ;with...

  • RE: Nth occurrence of a weekday in a month and year

    DECLARE @year VARCHAR(4),

    @month TINYINT,

    @weekday TINYINT,

    @iOccAt TINYINT

    DECLARE @dt DATETIME

    SELECT @iOccAt = 5,@weekday =6,@month = 5,@year = 2014

    select@dt= DATEADD(MM,@month-1,DATEADD(YYYY,@year-1900,0))+

    CASE WHEN ...

  • RE: Get the defination of all table type in database

    Hi ,

    The Script is going to give the create statement for all table data type which are present in the database.

    So you can get the all the table datatype create...

  • RE: MERGE Insert not working

    This is because there is no record into the Source table, try to verify with the some records into the source record.

    SET IDENTITY_INSERT LOAN_GROUP_INFO ON

    DECLARE @NEXT_ID AS INT = (SELECT...

  • RE: MERGE Insert not working

    IF Object_id('LOAN_GROUP_INFO') IS NULL

    CREATE TABLE LOAN_GROUP_INFO

    (

    LGI_GROUPLVR INT ,LGI_GROUPEXPOSURE INT ,LGI_DATECREATED DATETIMEOFFSET(3),LGI_CREATEDBY INT,LGI_DATEUPDATED DATETIMEOFFSET(3) ,LGI_UPDATEDBY INT ,LGI_ISACTIVE BIT,

    LGI_GROUPID INT IDENTITY (1,1)

    )

    GO

    IF Object_id('LOAN_GROUPING') IS NULL

    CREATE TABLE LOAN_GROUPING

    (

    LGI_GROUPLVR INT ,LGI_GROUPEXPOSURE INT ,LGI_DATECREATED DATETIMEOFFSET(3),LGI_CREATEDBY...

  • RE: MERGE Insert not working

    In this case you can use the Union in source query so the data can be validated

    MERGE INTO LOAN_GROUP_INFO AS TARGET

    USING (SELECT LGI_GROUPID FROM LOAN_GROUPING

    WHERE LG_LOANID = 22720

    AND...

Viewing 15 posts - 1 through 15 (of 89 total)