Viewing 15 posts - 271 through 285 (of 337 total)
DECLARE @NextMonth AS nvarchar(7)
SET @NextMonth = LEFT(datename(mm, dateadd(month, 1, GETDATE())), 3) + '-' + RIGHT(datename(yy, getdate()), 2)
if @nextmonth = 'Jan-10'
set @NextMonth = LEFT(datename(mm, dateadd(month, 1, GETDATE())), 3) + '-'...
December 16, 2010 at 3:39 am
Use Top clause without order by clause.
Select top 10 columnname from yourtable.
December 16, 2010 at 1:38 am
Not sure but try this
CAST(CASE
WHEN sp.[SalesPersonID] IS NULL THEN 0
ELSE 1
END AS BIT)AS [SalesPersonFlag]
December 15, 2010 at 10:54 pm
Are you sure you are getting the same value of Getdate() for each record ?
CREATE TABLE [dbo].[mfRepositoryErrors]
(
[errid] [int] NOT NULL,
[errorCode] [varchar](10) NOT NULL,
[description] [text] NULL,
[severity] [varchar](25) NULL,
[occurred] [datetime] NULL,
)
Insert into...
December 7, 2010 at 3:23 am
Jeff Moden (12/4/2010)
Sachin Nandanwar (12/3/2010)
December 7, 2010 at 3:01 am
Also it is a better idea to put the recover model to SIMPLE or else your log file will bloat.But make sure you take a Full and a T log...
December 3, 2010 at 10:47 pm
My attempt at this one.
declare @v-2 varchar(50)='StartDateEarlierThanCurrentDate'
declare @splitvalues varchar(50)=''
;with cte
as
(
select row_number()over(order by (select 1))id,SUBSTRING(@v,number,1)num,number from master..spt_values
where type='p' and number between 1 and LEN(@v)and SUBSTRING(@v,number,1)=UPPER(SUBSTRING(@v,number,1))
collate Latin1_General_CS_AS_WS
)
select @splitvalues=@splitvalues + '...
December 3, 2010 at 3:52 am
Something like this
select * from dbo.function1
Cross Apply dbo.function2
November 24, 2010 at 2:09 am
But what is the basis for your update?You want to update name to "C" wherever id=2 exists?
November 24, 2010 at 1:46 am
pramod_yg (11/24/2010)
Thanks Sachin. This one is totally new to me 🙂
You are welcome:-).Just incase you need to get weekday names you can replace month with weekday.
select DATENAME(WEEKDAY,GETDATE())
November 24, 2010 at 12:04 am
pramod_yg (11/23/2010)
I have a query. Is there any function what returns me the char value of month. i mean, i want Jan instead of 1. when i use Month(getdate())...
November 23, 2010 at 11:57 pm
luissantos (11/23/2010)
the script of Sachin is quiet perfect , but the unique problem is the result :
my invoice number 4562
i dont need the last number "2" of...
November 23, 2010 at 11:11 pm
Eralper (11/22/2010)
I guess what your are looking for is t-sql dense_rank() function
select
dense_rank() over (order by cat),
...
November 22, 2010 at 11:34 pm
It's quite difficult to give a solution without actually looking at the records which are causing the problem.
My wild guess would be use a dense_rank instead of row_number.
select
...
November 22, 2010 at 11:28 pm
Viewing 15 posts - 271 through 285 (of 337 total)