Someone good at Transact-SQL??

Results 1 to 3 of 3

Thread: Someone good at Transact-SQL??

  1. #1
    Wasabi Guest

    Default Someone good at Transact-SQL??

    I have this freaking text field in sql server, and i want to parse it at certain spots and get certain information out... that works fine...<BR>here&#039;s a sample of my sql statement...<BR><BR>Select substring(strings, 10, 20) As Directory,<BR> substring (strings, CHARINDEX(blah,blah), DETERMINEDLENGTH) As Filename<BR>from Files<BR><BR>Ok, great... now, i can&#039;t fix how the values are put into the database, it is Files as the only field. so, here&#039;s what i want to do...<BR><BR>I want to count all of the files that are in each folder.... i.e. count (Files) group by directory<BR><BR>only problem is Directory is not a column in the field... so SQL server won&#039;t let me group by and count Directory... does anybody have a very easy, SQL Side fix for this? (counting in asp takes too long, so i wanna pass it all to the sql server and get it back nice and ready for me.) Thanks for any help you can give me.<BR><BR>Wasabi

  2. #2
    Join Date
    Dec 1969

    Default No, but...

    ...since you can do this in Access, I&#039;d be surprised if you couldn&#039;t do it in SQL Server.<BR><BR>If you can create a substring expression that *is* the Directory portion of each file, why can&#039;t you GROUP BY that expression?<BR><BR><BR>SELECT Count(*), SUBSTRING_Expression AS optional_name<BR>FROM table<BR>GROUP BY SUBSTRING_Expression<BR>ORDER BY SUBSTRING_Expression<BR><BR>You have to actually repeat the same expression all three times; you can&#039;t just give it a name in the SELECT and then use it in the GROUP BY and ORDER BY.<BR><BR>Anyway, that works in both Access and MySQL, so hard to believe TSQL couldn&#039;t handle it.<BR><BR>

  3. #3
    Wasabi Guest

    Default Thanks

    but LOL!!<BR>Connection broken <BR>man, just when i get the **** SQL statement ready, they take down the am i supposed to get ANY work done?!<BR><BR>Wasabi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts