Viewing 15 posts - 3,736 through 3,750 (of 10,144 total)
Couple of small changes to MickeyT's otherwise excellent function:
DECLARE @code nvarchar(4000);
SET @code = '99944777777775588888888888812' ;
WITH cteTally as (
SELECT TOP(LEN(@code) - 1) ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) N
FROM (VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0))...
January 21, 2014 at 6:46 am
Use ROW_NUMBER().
If you can knock up a CREATE TABLE and a few INSERTs, someone will show you how.
January 21, 2014 at 6:17 am
Move your search predicates from the WHERE clause to the output. This a) gives you some output and b) shows you why it doesn't work:
--I'm not able to get results...
January 21, 2014 at 2:46 am
I can't tell what you are trying to do here because the numbers and the descriptions don't appear to match up. It doesn't make sense. Let's restructure your sample data...
January 21, 2014 at 2:17 am
As a frequent visitor to ssc you already know that you are more likely to get a tested and accurate solution if you provide sample data in a ready-to-consume format....
January 21, 2014 at 1:56 am
You can use replace:
SELECT *
FROM (SELECT ssn = '0123456789') d
CROSS APPLY (
SELECT
ssnAllway = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
ssnhalfway,
'a','3'),'b','9'),'c','1'),'d','6'),'e','2'),'f','8'),'g','0'),'h','7'),'i','4'),'j','5')
FROM (
SELECT
ssnHalfway = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
ssn,
'0','a'),'1','b'),'2','c'),'3','d'),'4','e'),'5','f'),'6','g'),'7','h'),'8','i'),'9','j')
) d
) y
SELECT *
FROM (SELECT ssn = '0123456789') d
CROSS APPLY (
SELECT
ssnAllway...
January 20, 2014 at 9:42 am
When the hour increments from one value to the next, or from 12 to 1, an hour boundary is said to have been crossed. The same happens for the other...
January 20, 2014 at 8:11 am
declare @data table (CorpId INT, Days CHAR(3), Value MONEY)
INSERT INTO @data
SELECT 1, 'Sun' , 789.00
UNION SELECT 1, 'TUe' , 66.00
UNION SELECT 1,'Thu' , 566.00
UNION SELECT 1,...
January 20, 2014 at 5:58 am
SELECT d.name
FROM (
SELECT
n2.name,
ct = COUNT(*) OVER(PARTITION BY n1.name)
FROM names n1
INNER JOIN names n2 ON n1.name LIKE '%'+n2.name+'%'
) d
WHERE ct > 1
January 20, 2014 at 2:22 am
ramachandran narayanan (1/19/2014)
...I have table called 'UserDetails'. If I execute below select queryit should display in order of uno= 7,13,5 but i get in order of
uno=5,7,13....
What are the business...
January 20, 2014 at 1:39 am
This looks like the output from a CROSSTAB query. If so, you would normally aggregate across whatever the partition is and use MAX() on each column value. Post your query...
January 17, 2014 at 9:47 am
For testing purposes, comment out the INSERT part of the batch. Run this test batch a couple of times to obtain a performance baseline.
The difference between actual and estimated...
January 17, 2014 at 2:29 am
Abu Dina (1/16/2014)
SELECT * FROM SSC2 AS a WHERE EXISTS (SELECT ID, Name FROM SSC1 AS b WHERE a.ID =...
January 16, 2014 at 3:32 am
The message you're getting suggests you have a trigger on the table you are deleting from, and that the trigger has been written to handle single-row changes, not the set-changes...
January 16, 2014 at 1:44 am
Viewing 15 posts - 3,736 through 3,750 (of 10,144 total)