Viewing 3 posts - 1 through 3 (of 3 total)
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...
September 17, 2013 at 1:14 am
Declare all variable used in dynamic query as nvarchar or varchar. It will work for sure.
August 30, 2013 at 6:29 am
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...
November 6, 2009 at 3:05 am
Viewing 3 posts - 1 through 3 (of 3 total)