Roy Ashbrook

let go or be dragged
posts - 198, comments - 29, trackbacks - 8

August 2010 Entries

Search all of the text fields in a sql server database for a particular value… with LINQ (Pad)

So, the question was posed on how to do this with LINQPad, and thus with LINQ. Here is one way. This is basically the same thing I did in my last post about searching for this kind of value. This also shows how to return an arbitrary result from a linq query to a very generic class object for later processing. Note that I was not able to use params because the table name couldn't be a param. I'm sure there is probably some more elegant way to do this, but this works fine and hopefully this is one of...

posted @ Monday, August 30, 2010 6:32 PM | Feedback (0) |

Search all of the text fields in sql server database for a particular value

-- try and do dirty reads, and turn off the record counting unless you want -- spam in the middle of your prints below. you can also just do a select -- instead of a print. set transaction isolation level read uncommitted set nocount on  -- vars to hold the commands to queue up and the command var for the one we'll run -- identity is used to preserve order in case we decide to have a particular order -- otherwise it will just run in the order we create the commands declare @command nvarchar(max), @id int declare @commands table(id int IDENTITY(1,1) PRIMARY KEY CLUSTERED, command nvarchar(max))  -- strint to look for declare @StringToFind...

posted @ Monday, August 30, 2010 3:23 PM | Feedback (0) |

LINQPad and Active Directory

I am a huge fan of LINQPad. Something on my wish-list, as far as my own personal knowledge, for a longtime with it was how to query Active Directory information when I needed it. This was more for convenience because quite often I need to look up some AD info when I am looking at a scrub for some data regarding a user. Normally I just net use or dsquery/dsget etc. The key is System.DirectoryServices.AccountManagement. Note this is a .NET 3.5 and 4.0 only library so earlier than that, sorry. You aren't out of luck, but the other ways seem...

posted @ Friday, August 20, 2010 4:13 PM | Feedback (0) |

set transaction isolation level read only uncommitted in LINQ

apparently you can use a transaction scope for this and just wrap everything that way. but to me that seems more complicated than just enabling it with execute command.   some LINQ code like (note that ‘this’ is a data context): this.ExecuteCommand("set transaction isolation level read uncommitted"); MyTable.Take(5).Dump(); Produces this sql code: set transaction isolation level read uncommitted GO SELECT TOP 5 <fieldnames…> FROM [MyTable] AS [t0] GO   That’s what I want to see, so yay. =)     some links:   ps. trying to use livewriter today. so far, not excited about it and still like word more =P hopefully i’ll get elightened.

posted @ Friday, August 13, 2010 10:43 AM | Feedback (0) | Filed Under [ DEV ]

Space used by tables, long form

After my recent post, I had a couple of conversations and an email exchange with a colleague of mine and I was reminded of the fact that I went originally out to search for my 'original' table space used script. I couldn't find it online (even though I found it on my hdd) and that prompted me to put together the newer method. Which is considerably shorter. But here is my original script which essentially I wrote by looking at what was in sp_spaceused and just formatting it more to my liking.  -- view all table sizes -- author: royashbrook - --...

posted @ Tuesday, August 3, 2010 12:08 PM | Feedback (0) |

Powered by: