Forum Replies Created

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

  • RE: Update Table - By Looping Through Field Name

    This might hep for n number of columns :

    *********************************************************************************************

    DECLARE @Q NVARCHAR(4000),

    @CName VARCHAR(255)

    DECLARE ColCur CURSOR

    FOR

    SELECT C.name as Column_name

    FROMsys.columns C

    LEFT JOIN sys.tables t

    on C.object_id = t.object_id

    WHEREt.name = 'Your_table'

    OPEN ColCur

    FETCH NEXT...

  • RE: Dynamic SQL and DATEADD with User Defined Variable in Number/2nd position

    Declare all variable used in dynamic query as nvarchar or varchar. It will work for sure.

  • RE: Problems coverting string to SQL Server datetime

    declare @date varchar(50)

    declare @converted_date datetime

    set @date = '20091102165659'

    set @converted_date = (select substring(@date,0,5)+'/'+ substring(@date,5,2)+'/'+ substring(@date,7,2)+' '+ substring(@date,9,2)+':'+

    substring(@date,11,2)+':'+substring(@date,13,2))

    print @converted_date

    try this.Not the efficient one. But last...

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