Saturday, October 12, 2013

[T-SQL] set date/time to today date but certain time

[T-SQL] set date/time to today date but certain time


set date/time to today date but certain time

Posted: 11 Oct 2013 01:36 AM PDT

Hi -What is a best way to set a field value to today date and time would be a always set to 4:00:00? Please advice

Pass a table variable column value to a SP output variable

Posted: 11 Oct 2013 01:13 AM PDT

How to pass a table variable column value to a SP output variableI want the values in column v (table variable column) to be assigned to @HCodes(SP output variable)I have a query like this:DECLARE @MaterialCode varchar(max)SELECT @MaterialCode = materialItemCode FROM local_MaterialsItemsContainers MICINNER JOIN local_MaterialsItems MION (MIC.materialItemIncId = MI.materialItemIncId AND MIC.materialItemSqlId = MI.materialItemSqlId AND MI.isDeleted=0x0)WHERE charindex(MIC.materialItemContainerCode,'MC-00000030-13-0001')<>0select @MaterialCodeDECLARE @HCodes nvarchar(MAX)declare @t table (id int identity(1, 1), v varchar(50))INSERT @tSELECT LH.hazardCode from Local_MaterialsItems MI INNER JOIN Local_MaterialsItemsHazards MIH on MI.materialItemIncId = MIH.materialItemIncId AND MI.materialItemSqlId = MIH.materialItemSqlId INNER JOIN Local_Hazards LH on MIH.hazardIncId = LH.hazardIncId AND MIH.hazardSqlId = LH.hazardSqlIdwhere charindex(MI.materialItemCode,@MaterialCode)<>0declare @Numbers table (i int identity(1, 1), j bit)insert into @Numbers select top 50 null from master.dbo.syscolumns a, master.dbo.syscolumns bselect distinct left(substring(','+v, i + 1, 50), charindex(',', substring(','+v+',', i + 1, 50))-1) as vfrom @t t, @Numberswhere substring(','+v, i, 1) = ','order by v

No comments:

Post a Comment

Search This Blog