August 12, 2005 at 11:51 am
This is not rocket science. A guy has a stupid kid game he sells on a cd. I got hired to write a scaled-down web demo of it. The XML file it uses has the data laid out that way. I imported it to SQL and presto..this stupid-little-kinda problem that pops up once and awhile. I CAN fix the problem in ASP but I wanted a slick SQL solution...not change the figging database. Maybe it just can't be done.
August 12, 2005 at 11:52 am
That's what we told you in a not too beautiful way. Good luck with that project.
August 12, 2005 at 12:02 pm
"Some of you guys need to date more!"
Gee I knew that. Remi plays pool but I could use a few phone numbers.
Mike
August 12, 2005 at 12:06 pm
I would date more, but it would interfere with my work, pool and or social life so I refrain from it .
August 12, 2005 at 12:08 pm
You know what would be funny?...if this was a sample question on a job interview. Given the data & structure of the table, there must be a way to accomplish this in SQL Server. Next week I will figure it out and post it here! I'm too tired today!
'It's not necessary to knock the whole building down to change a light switch on the third floor!'
August 12, 2005 at 12:14 pm
This is a classic scenario of:
Fast,Cheap,Good --> Pick Two
I have been in that possiton quite a bit and even after my recommendation I have implemented the WRONG approach because the one who was signing my pay check said so!!! Therefore I don't blame you
And about the Dating issue.... I would make no comments either
* Noel
August 12, 2005 at 12:18 pm
I wouldn't make any comments on the dating issue either except to say that I've told remi only about 10 times in as many weeks to G.A.L....
**ASCII stupid question, get a stupid ANSI !!!**
August 12, 2005 at 12:26 pm
Bob, I know this can be done, but that can't really be error proof (good pick). I know you can do it on the server, but you basically combine what you want to do in asp and what we provided in sql server which is a worst practice. If you think this is the best path for this contract, I have no problem with that. But I'll keep answering the questions like I do now because I want to pick GOOD, FAST and cheap if possible.
August 12, 2005 at 12:26 pm
I'm gonna say this one last time Sushila. I wanna freaking turn PRO and make a living a playing pool, so THAT'S MY LIFE.
August 12, 2005 at 12:30 pm
okay remi (sheesh!)...backing off (& down) real slow here...SORRY if I've stepped on any toes...
**ASCII stupid question, get a stupid ANSI !!!**
August 12, 2005 at 12:39 pm
Like my friend told me once... it's not what you said.. it's the accumulation...
August 12, 2005 at 12:48 pm
okay - i hate being yelled at so that's the last time you'll hear it from me!
**ASCII stupid question, get a stupid ANSI !!!**
August 12, 2005 at 12:51 pm
Sorry if I offended you but I don't like having my life thrown in the dirt.
August 16, 2005 at 8:38 am
Are you girls still out there?
How would you pass a sting of numbers to a stored proc...ie
@myVar='10,80,90'
then in the sp use as
Select ..... NOT IN @myVar
It don't work like this..
-Bob
August 16, 2005 at 8:51 am
IF Object_id('fnSplit_Set') > 0
DROP FUNCTION dbo.fnSplit_Set
GO
IF Object_id('Numbers') > 0
DROP TABLE dbo.Numbers
GO
CREATE TABLE dbo.Numbers (PkNumber int identity(1,1), dude bit null, CONSTRAINT Pk_Number PRIMARY KEY CLUSTERED (PkNumber))
GO
INSERT INTO dbo.Numbers (dude)
SELECT NULL FROM (SELECT TOP 100 NULL AS A FROM master.dbo.spt_values) dt100 cross join (SELECT TOP 80 null AS A FROM master.dbo.spt_values) dt80
GO
ALTER TABLE dbo.Numbers
DROP COLUMN dude
GO
--Select min(PkNumber) as MinA, max(PkNumber) as MaxA from dbo.Numbers
--1, 8000
GO
CREATE FUNCTION [dbo].[fnSplit_Set] (@IDS as varchar(8000), @vcDelimiter varchar(3))
RETURNS TABLE
WITH SCHEMABINDING
AS
Return
Select dtSplitted.EachID, dtSplitted.Rank from (
SELECT SUBSTRING(@vcDelimiter + @IDs + @vcDelimiter, N.PkNumber + len(@vcDelimiter),
CHARINDEX(@vcDelimiter, @vcDelimiter + @IDs + @vcDelimiter, N.PkNumber + len(@vcDelimiter)) - N.PkNumber - len(@vcDelimiter)) as EachID
, (LEN(SUBSTRING(@IDs, 1, N.PkNumber)) - LEN (REPLACE (SUBSTRING(@IDs, 1, N.PkNumber), ',', ''))) + 1 AS Rank
FROM dbo.Numbers N
WHERE SUBSTRING(@vcDelimiter + @IDs + @vcDelimiter, N.PkNumber, len(@vcDelimiter)) = @vcDelimiter
AND PkNumber 0
GO
DECLARE @Ids as varchar(8000)
SET @IDS = ''
Select @IDS = @IDS + CAST(id as varchar(10)) + ',' from (Select TOP 10 id from dbo.SysObjects order by NEWID()) dtIds
SET @IDS = left(@IDS, ABS(len(@IDS) - 1))
PRINT @IDS
Select O.id, dtIDS.EachId, O.name, dtIDS.Rank from dbo.SysObjects O inner join (Select CAST(EachID as INT) AS EachID, Rank from dbo.fnSplit_Set (@IDS, ',')) dtIDS on O.id = dtIDS.EachID order by O.Name
Select O.id, dtIDS.EachId, O.name, dtIDS.Rank from dbo.SysObjects O inner join (Select CAST(EachID as INT) AS EachID, Rank from dbo.fnSplit_Set (@IDS, ',')) dtIDS on O.id = dtIDS.EachID order by dtIDS.Rank
--Dont't ever forget to cast the eachid column to the same datatype as in the join to avoid table scans.
Viewing 15 posts - 31 through 45 (of 55 total)
You must be logged in to reply to this topic. Login to reply