Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

Need advice ...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shapper - 14 Feb 2008 02:39 GMT
Hello,

I have a SQL table to hold files information.
One of the table columns is Path which holds values as:

C:\Assets\MyPic.jpg
C:\Assets\MyCV.doc
...

I need to get all record which are images, i.e., which extension
is .jpg, .gif, .png.

Should I use a SQL Stored Procedure or LINQ to filter the paths which
end with the desired extensions?

OR

Should I create, instead, a column named Type and before I insert a
record I would detect in my C# code the file type and fill the Type
column with it?

How is this usually done?

Thank You,
Miguel
Misbah Arefin - 14 Feb 2008 03:03 GMT
There are a number of ways you can do this it all depends on the QOS
requirements of your application there are tradeoffs with each approach

using stored proc to query you would have to use something like
WHERE Path LIKE '%.jpg' OR Path LIKE '%.gif' etc
this would use an "Index Scan" and depending on the number of rows in your
table might take a lot of time for the query to execute

another approach would be to create a IsImage (BIT) column (also create
index on this column) which you could populate during your insert - your
where clause would be something like
WHERE IsImage = 1
this would use an "Index Seek" which would be faster than the WHERE Path
LIKE approach

another solution instead of explicitly setting the value of the IsImage
column via code let SQLServer do that for you - you would have to make the
IsImage column a computed column and make it persist so that it is not
calculated each time rather only during insert and updates to the row

using LINQ vs SP I would say use SP if the number of rows in the table are
expected to be huge

--
Misbah Arefin

> Hello,
>
[quoted text clipped - 21 lines]
> Thank You,
> Miguel
Zeeshan Haider - 14 Feb 2008 03:09 GMT
I absoulatlely agree with Misbah.

> There are a number of ways you can do this it all depends on the QOS
> requirements of your application there are tradeoffs with each approach
[quoted text clipped - 47 lines]
> > Thank You,
> > Miguel

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.