Forum Replies Created

Viewing 14 posts - 1 through 14 (of 14 total)

  • RE: contraints syntax and script

    oops.. second part of previos script

    OPEN i

    FETCH NEXT FROM i INTO @table_name, @constraint_name

    WHILE @@fetch_status=0

    BEGIN

    --EXEC('ALTER TABLE '+@table_name+' DROP CONSTRAINT '+@constraint_name)

    PRINT 'ALTER TABLE '+@table_name+' DROP CONSTRAINT '+@constraint_name

    FETCH NEXT FROM i INTO @table_name,@constraint_name

    END

    CLOSE...

  • RE: contraints syntax and script

    --Drop all FKs in the database for the selecting tables

    DECLARE

    @table_name sysname,

    @constraint_name sysname

    DECLARE i CURSOR STATIC

    FOR

    SELECT

    c.table_name,...

  • RE: How to find max value in which column

    one scan table [Result] only

    select total_res, [subject]

    from

    (

    select total_res = SUM(CAST(res AS Int)), [subject]

    from

    (

    select *

    ...

  • RE: Passing a Constant in a query which is stored in a variable.

    set @sql1 = 'SELECT COUNT(*) FROM "HRDATAMART_DAILY"."dbo"."EMPLOYEE" WHERE EMP_MOST_RECT_HIRE_DT IS NULL AND SOURCE_NM = '''+@constant1+''''

    🙂

  • RE: Logging Raiserror log messages into a table

    another way

    put into job (named 'test' ) step procedure execution only

    DECLARE

    @job_id uniqueidentifier

    SELECT

    @job_id = sv.job_id

    FROM

    msdb.dbo.sysjobs_view AS sv

    where name ='test'

    ORDER BY

    [Name] ASC

    declare @tmp_sp_help_jobhistory table

    (

    ...

  • RE: Logging Raiserror log messages into a table

    put procedure execution into job's step

    /*

    CREATE PROCEDURE test

    AS SELECT 1/0

    GO

    */

    BEGIN TRY

    EXEC test

    END TRY

    BEGIN CATCH

    --INSERT [Your Table]

    SELECT

    ERROR_NUMBER() ...

  • RE: Logging Raiserror log messages into a table

    BEGIN TRY

    RaisError...

    END TRY

    BEGIN CATCH

    INSERT [Your Table]

    SELECT

    ERROR_NUMBER() AS ErrorNumber,

    ERROR_SEVERITY() AS ErrorSeverity,

    ...

  • RE: need to format sql query output in physical xml output file

    FOR XML RAW (''), ELEMENTS , ROOT ('Item') ?

  • RE: Travel Planner SQL

    declare @table table (rowid int,value1 varchar(2),value2 varchar(2))

    declare @table1 table (value varchar(220))

    declare @first_Letter varchar(2)= 'A'

    declare @last_Letter varchar(2)= 'F'

    insert into @table

    Select 1,'A','B'

    union Select 2,'C','D'

    union Select 3,'E','F'

    union Select 4,'G','H'

    ;with t2 as(

    select

    ...

  • RE: date time diff

    Check variables type

    declare @d int /*datetime*/ --<<-- datetime wrong variable type

    declare @m int /*datetime*/

    declare @y int /*datetime*/

    declare @result varchar(50)

    set @d= datediff(dd,'01/01/2010','01/03/2010')

    set @m=datediff(mm,'01/01/2010','01/03/2010')

    set @y=datediff(yy,'01/01/2010','01/03/2010')

    set @result=right('00'+convert(varchar,@d,102),2) + ''...

  • RE: Format varchar value to numeric

    mega solution 🙂

    SELECT [Tarief], [Tarief2]= cast(0.01*[Tarief] as varchar) FROM @TABLE

  • RE: Hirerchy Query Help Required

    use tempdb

    go

    if OBJECT_ID('[dbo].[Menu]', 'U') is null begin

    create table [dbo].[Menu]

    (

    menu_id int primary key,

    menu_name varchar(100)

    )

    ...

  • RE: How to select 1 column into different rows and columns

    ;WITH s as (SELECT id=row_number()over(order by (select 0))

    FROM(SELECT 1a,1b,1c,1d,1z,1f,1g,1h,1i,1j,1k)E

    ...

  • RE: i need a query tip

    canuzun (6/28/2010)


    Thanks for the tip.

    Only curious, is it possible to create the second table, from the first one with single query?

    Possible

    SELECT

    CUSTOMER_ID ...

Viewing 14 posts - 1 through 14 (of 14 total)