Viewing 15 posts - 1 through 15 (of 31 total)
Hakim:
Why do you need to join the system view syscomments twice? I think you only need to alias it once. Here is the modified code:
selectdistinct
ObjectType= o.type_desc
,ObjectName= o.name
,CodeSequence= c_display.colid
,Code=...
April 10, 2015 at 7:28 am
Bob:
Thanks for your reply.
Sorry I sent you a salutation of "SSCrazy"!
--Jeff
February 4, 2010 at 10:21 am
SSCrazy:
Look at Julie Breuntzmann's post just before mine. I think you also need to cast the varchar(max) to a text data type:
update sample
SET data = CAST(REPLACE(CAST(data AS VARCHAR(MAX)),'b','|') AS...
February 4, 2010 at 12:49 am
Try this solution that first copies the table to a temp table (or table variable), but defines the text column as a varchar(max). Then you can use the REPLACE...
February 2, 2010 at 7:06 pm
Knockyo:
Try this. For @SelectColNames, you simply want to replace all occurrences of '] ,' with ']+'.
Therefore,
select DISTINCT
CapitalForecastID
,Description
,BudgetOwnerName
,CapitalForecastCostPerUnit
,' +
'SUM(' +
LEFT(REPLACE(@SelectColNames, '] ,', ']+'),...
January 29, 2010 at 12:09 am
Rather than using complex CASE WHEN logic to generate your ORDER BY clause, why not use the following IF...ELSE logic?
declare @t table (c1 int, c2 varchar(50))
declare @sortorder int
insert...
January 21, 2010 at 7:28 pm
One final update to my solution. Using CTE's, the output query is much easier to understand.
Here is the complete script:
create table #temp
(
name varchar(4),
age int,
sex varchar(1)
)
insert #temp
select 'ABC',24,'M'
union all
select...
November 2, 2009 at 11:41 am
Thanks for your comments. The following modified solution works when you use the row_number() function to number the rows in an output query.
For the following query, the output for...
November 2, 2009 at 10:50 am
Maybe I'm missing something, but the query the original poster was looking for is simple with the appropriate GROUP BY and HAVING clauses.
SELECT Name, Age, Sex
FROM Source
GROUP BY Name,...
November 1, 2009 at 5:20 pm
Lynn:
Oops!!!!
I misread his second note that says he wanted to remove a fixed position, whether or not it's an 'H'. My solution would work if he wanted to remove...
July 14, 2009 at 11:26 am
Lynn:
I'm not trying to give you a hard time, but look at his second post that I copied above!!!!
--Jeff
July 14, 2009 at 11:23 am
Lynn:
The original poster's second note says:
"The problem is that this character is not always H, it can be any character. How can I use the Len function to get a...
July 14, 2009 at 10:54 am
The STUFF function should only be executed if the 10th character is an 'H'. Therefore, the STUFF function should be used in combination with a SUBSTRING function and a...
July 14, 2009 at 9:42 am
Jacob:
Great article!
I think I spotted a small error in sprocs ProductSearch6 and ProductSearch7 when a search parameter is not Null, and you are using the LIKE operator. You should...
August 30, 2008 at 9:29 am
I agree with SSC Eights for the third solution!!!!!
Here it is:
SELECT DATEDIFF(yy, DateOfBirth, GETDATE()) -
CASE WHEN (DATEPART(m, DateOfBirth) > DATEPART(m, GETDATE()) OR
(DATEPART(m, DateOfBirth) = DATEPART(m, GETDATE())
AND (DATEPART(d,...
March 6, 2008 at 9:57 am
Viewing 15 posts - 1 through 15 (of 31 total)