我不擅長t-sql,所以我需要幫助。如果在sql中構建
我有這樣的代碼,我寫我自己,但怎麼寫,我想我不知道(與英語難過)
declare @questionid int
set @questionid = 22
declare @providerid int
set @providerid = 189
select [closed] into #question from [Data].[dbo].[Question] where [questionid] = @questionid
-- and here, if [closed] is null I must write in the question table current date GETDATE()
UPDATE [Data].[dbo].[Question] SET [closed] = GETDATE() WHERE [questionid] = @questionid and [providerid] = @providerid
-- or, if [closed] is not null I must write there null
UPDATE [Data].[dbo].[Question] SET [closed] = null WHERE [questionid] = @questionid and [providerid] = @providerid
drop table #question
我怎麼能這樣做?
它能夠更好地去情況時,這是緊湊...並保存額外的行,使代碼清晰... – 2012-03-26 13:34:20
@Pranay林蛙你是正確的 – Wachburn 2012-03-26 13:40:44