Viewing 15 posts - 9,601 through 9,615 (of 10,144 total)
shuzi (9/9/2008)
so how to retrieve the middle value, e.g. A104 and A101thanks
The middle value of how many values? Will it always be three?
Looks like this is going to...
September 9, 2008 at 8:44 am
something like this?
DROP TABLE #buildings
CREATE TABLE #buildings (building int, unit varchar(4), sort_order int)
INSERT INTO #buildings (building, unit, sort_order)
SELECT 1, '101', 1 UNION ALL
SELECT 1, '102', 2 UNION ALL
SELECT 1, '103',...
September 9, 2008 at 8:15 am
Hi Chris
IF is for conditional execution of statements within a batch. Use CASE for conditions within a statement. Check out CASE in BOL, there are two types, simple and searched....
September 9, 2008 at 4:04 am
September 8, 2008 at 10:27 am
Hi Chris
It's a kinda cross-post, Matt is dealing with it too:
http://www.sqlservercentral.com/Forums/Topic565481-8-1.aspx
Cheers
ChrisM
September 8, 2008 at 10:26 am
Could be significant with OP's data too:
SELECT note,
PATINDEX('%,[0-9][0-9],',note) AS A,
PATINDEX('%[0-9][0-9]',note) AS B,
...
September 8, 2008 at 10:18 am
Does it work? What's it supposed to do? It doesn't return results where ',[0-9][0-9],' is in the rightmost part of the column...
SELECT note,
PATINDEX('%,[0-9][0-9],',note) AS A,
PATINDEX('%[0-9][0-9]',note) AS B,
SUBSTRING(note, PATINDEX('%[0-9][0-9]',note),...
September 8, 2008 at 9:38 am
That's because you're expecting this section...
(SELECT TOP 1 TargetID
FROM ##T2 where TargetID not in...
September 8, 2008 at 9:24 am
You could account for the spaces as follows. There's a system proc too:
[font="Courier New"]DECLARE @cVersion VARCHAR(5)
SELECT @cVersion = CASE WHEN UPPER(REPLACE(@@version, ' ', ' ')) LIKE 'MICROSOFT SQL SERVER 2000 %'...
September 8, 2008 at 9:07 am
Hi David
@@VERSION:
DECLARE @cVersion VARCHAR(200)
SELECT @cVersion = @@version
SELECT SUBSTRING(@cVersion, 23, 4)
...you could use conditional processing on the result.
Cheers
ChrisM
September 8, 2008 at 8:27 am
[font="Courier New"]-- Set up some test data
CREATE TABLE ##T2 (TargetID smallint)
INSERT INTO ##T2
SELECT 1 UNION ALL
SELECT 2 UNION ALL
SELECT 3 UNION ALL
SELECT 4 UNION ALL
SELECT 5 UNION ALL
SELECT 6...
September 8, 2008 at 7:22 am
bhuvnesh.dogra (9/8/2008)
On what basis you want to update targetid in T2 from T1there shud be some criteria or condition 😉
Random - that's the point.
It looks very like a...
September 8, 2008 at 6:48 am
Bhuvnesh,
SQL Server detects that the columns are missing before running the code, but doesn't see that the new columns are added to the table in step 2.
However, you don't need...
September 8, 2008 at 2:33 am
Viewing 15 posts - 9,601 through 9,615 (of 10,144 total)