Viewing 15 posts - 256 through 270 (of 423 total)
Here you go:
SELECT
b.ID1
,b.ID2
,(SELECT COUNT(DISTINCT X1) FROM #Table1 WHERE ID1=b.ID1 AND ID2=b.ID2 AND NULLIF(X1,'') IS NOT NULL) AS X1Count
...
February 14, 2013 at 7:50 pm
Just to demonstrate something, consider again Lynn's example which does an implicit conversion.
DECLARE @MWBS INT, @Result CHAR(1)
SET @MWBS = 0
SELECT
@Result =
(CASE...
February 14, 2013 at 7:00 pm
On the SQL side if you want any zeroes to be null you do this:
SELECT NULLIF(fooval,0) AS foonull FROM foo
If you need to validate all values you can do something...
February 13, 2013 at 12:05 pm
The problem may be as simple as redefining your DECIMAL datatype conversion. Below I do the replace and ISNUMERIC check in one pass then only CAST values that meet that...
February 13, 2013 at 11:06 am
--this would be your original source table
IF OBJECT_ID('tempdb..#SourceTable') IS NOT NULL
DROP TABLE #SourceTable
CREATE TABLE #SourceTable (
[ID] INT IDENTITY(1,1) NOT NULL,
[Name] NVARCHAR(50) NULL,
PRIMARY KEY (ID))
SET IDENTITY_INSERT #SourceTable ON
INSERT INTO #SourceTable (ID,Name)
SELECT...
February 12, 2013 at 4:02 pm
newbie2 (2/12/2013)
February 12, 2013 at 3:40 pm
By coincidence one of my colleagues asked me this afternoon how to do a hierarchical query. So I dug out something from my toolbox. Here's a scrubbed down generic version...
February 12, 2013 at 3:04 pm
sku370870 (2/12/2013)
Is there some advantage to creating the sort key in the form you used (using REPLICATE etc.)?
At least with this sort key method you have to keep in mind...
February 12, 2013 at 11:10 am
The databases I work on usually belong to clients and already have a schema. Often these instances are full of third-party objects with all kinds of naming conventions. So even...
February 11, 2013 at 9:40 pm
Steven Willis (2/11/2013)
...I can't guess what effect this would have on performance of the function.
I was wondering about that! Thanks for doing the proof testing.
February 11, 2013 at 9:16 pm
You have what you need right there already (except maybe a sort value to break ties...I used FTIDCalc for that). I created an artificial sort key based on your parent-child...
February 11, 2013 at 9:05 pm
Sorry Sean...I didn't see that you had already answered with exactly the same idea. 😛
February 11, 2013 at 3:28 pm
ahpitre (2/11/2013)
February 11, 2013 at 3:26 pm
You can evaluate the expression by using dynamic SQL.
There's no double-pipe in SQL. Usually X || Y means X OR Y except that Y is not evaluated if X...
February 10, 2013 at 12:21 am
Viewing 15 posts - 256 through 270 (of 423 total)