View Full Version : sql query
in a break from tradition for this place, i actually need some assistance that is work related, so im posting it in the working hours section...
ive written for the following query:
declare @contno varchar(10), @filename varchar(128), @name varchar(128), @i int
select @contno='CEN/003469', @filename='', @name=''
DECLARE doc_cursor CURSOR FOR
SELECT [filename],[name] FROM ContDoc where contno=@contno
OPEN doc_cursor
FETCH NEXT FROM doc_cursor
INTO @filename, @name
WHILE @@FETCH_STATUS = 0
BEGIN
exec master..xp_fileexist @filename, @i out
if @i=1
print ''+@contno+': '+@filename+' exists'
else
print ''+@contno+': '+@filename+' does not exist'
END
CLOSE doc_cursor
DEALLOCATE doc_cursor
this query is meant to utilise the xp_fileexist route to scan the filesystem and check if the file exists, however upon run it just sits there indefinitely (4 minutes so far)
any ideas?
nevermind, worked it out myself coz i r leet
SET NOCOUNT ON
declare @contno varchar(10), @filename varchar(128), @name varchar(128), @i int
select @contno='CEN/003469', @filename='', @name=''
DECLARE doc_cursor CURSOR FOR
SELECT [filename],[name] FROM ContDoc where contno=@contno
OPEN doc_cursor
FETCH NEXT FROM doc_cursor
INTO @filename, @name
WHILE @@FETCH_STATUS = 0
BEGIN
exec master..xp_fileexist @filename, @i out
if @i=1
print ''+@contno+': '+@filename+' exists'
else
print ''+@contno+': '+@filename+' does not exist'
FETCH NEXT FROM doc_cursor
INTO @filename, @name
END
CLOSE doc_cursor
DEALLOCATE doc_cursor
the only thing that springs to mind is why the fuck are you doing a os file check in a stored proc oO your locking a db read thread for checking a file system you'd be much better doing that check in code than in query.
quick fix on a customers system :)
you are hense forth banned from touching code tbh :)
its not a quick fix that has come about due to my own oversight, i got reassigned on friday from development to 3rd line support (i have a whole team consisting of just me) to bridge the gap between development and support... i still get to step through code for problem shooting but now i just have a job that i can do while half asleep, which is excellent for me...
the code that this is quickfixing is several years old so far predates me joining the company... and there is only one site out of thousands with the problem
Conclusion: Never let a Danish company design your sql infrastructure.
Na im just being a meanie...
im surprised i didn't get a 'thats a lil geeky for a girl' etc, thats what i got from the guys on support after writing this for them :/
i know a fair few females who are very very good coders i see no reason why a girl can't do this job as good as any male just most of them don't choose this directly in career as they see it as too geeky themselves
exactly what i said! i duno i just guess most guys are still a lil unused to the fact
I see lots of girls at car shows and stuff (not working there) with some serious cars.
Some of them like to make it a point that they are girls, one of them has an expensive bra in a custom fabricated and lit display case in the trunk of her S15.
I should do the same with my skid marked grundies, wonder if it will generate the same effect.
i see people slipping off topic :P
I'm just keeping up with traffic :P
That's a mighty fine query you have there, top draw
are you being sarcastic again giga?
are you being sarcastic again giga?
No didn't you know, giga is like one of the best 0.1% sql experts in the world...
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.