David Yardy PE, MCSD.NET

just give me the source...

SQL Server – Find Field Value in Database

posted @ Saturday, August 16, 2008 11:23 AM | Feedback (0)

The following is a SQL Script that can be run in a database to return all tables and columns where a particular value is present.  This can be used for strings or values with a small modification.

This type of thing is great when moving applications/products between servers.  This is certainly a good script to include in your master table to be used over and over.

DECLARE @value VARCHAR(64)
DECLARE @sql VARCHAR(1024)
DECLARE @table VARCHAR(64)
DECLARE @column VARCHAR(64)

SET @value = 'valuehere'

CREATE TABLE #t (
    tablename VARCHAR(64),
    columnname VARCHAR(64)
)

DECLARE TABLES CURSOR
FOR

    SELECT o.name, c.name
    FROM syscolumns c
    INNER JOIN sysobjects o ON c.id = o.id
    WHERE o.type = 'U' AND c.xtype IN (167, 175, 231, 239)
    ORDER BY o.name, c.name

OPEN TABLES

FETCH NEXT FROM TABLES
INTO @table, @column

WHILE @@FETCH_STATUS = 0
BEGIN
    SET @sql = 'IF EXISTS(SELECT NULL FROM [' + @table + '] '
    --SET @sql = @sql + 'WHERE RTRIM(LTRIM([' + @column + '])) = ''' + @value + ''') '
    SET @sql = @sql + 'WHERE RTRIM(LTRIM([' + @column + '])) LIKE ''%' + @value + '%'') '
    SET @sql = @sql + 'INSERT INTO #t VALUES (''' + @table + ''', '''
    SET @sql = @sql + @column + ''')'

    EXEC(@sql)

    FETCH NEXT FROM TABLES
    INTO @table, @column
END

CLOSE TABLES
DEALLOCATE TABLES

SELECT *
FROM #t

DROP TABLE #t

One Hundred Pushups – oh ya for real

posted @ Sunday, August 10, 2008 10:25 PM | Feedback (1)

Back from vacation and back into the routine of work and I am ready to get in shape.  City living and a ‘developers’ lifestyle has left my body in rough shape.

My wife and I recently invested in some home exercise equipment and I assembled it today.  I was scanning some blogs this evening and came across a couple of other individuals in similar modes.  Rob Conery posted about the onehundredpushups ‘program’ and thought this is good timing.

So my goal is to do my time (2 – 30 minute sessions) on our home equipment daily as well as the 100 pushup plan.  I did the initial test and with sore arms I completing this post.

For my friends out there, if you also get involved and do the program with me (and complete it) I will buy and have delivered your choice of merchandise from their site.  Let me know if this sounds too good. I am serious.

I start day 1 tomorrow.  Let me know if you like my offer.

Developer Humour – Real Technology Heroes

posted @ Saturday, August 09, 2008 11:11 PM | Feedback (0)

As you are listening to these realize that it is impossible not to think of someone you know.  That is just funny.

It Works on My Computer Guy - “dozens of dependencies”, “replace the production server with your development pc” - “all in a days work”

Overly Complicated App Guy – “18 abstraction layers”, “what the hell were you thinking”

Mr “I can build your own version of asp.net better than Microsoft” Guy – very very funny!!

SQL Server 2008 Installation – not so quick

posted @ Thursday, August 07, 2008 11:29 PM | Feedback (0)

Before you rush to download SQL 2008 you may want to read the following KB article which warns that Visual Studio 2008 SP1 ‘may be required’ for SQL Server 2008 installations KB956139 (found here)

”Because certain SQL Server 2008 features install components that are also part of the release version of Visual Studio 2008 SP1, SQL Server 2008 requires Visual Studio 2008 with SP1. If Visual Studio 2008 without a service pack is installed instead, it may not work correctly after you install SQL Server 2008.“

Currently Visual Studio 2008 Service Pack 1 (SP1) is in beta at the current time.  I do not know the expected delivery of SP1 but should be soon (hang tight).

category: SQL Server

Internet Explorer Default Source Editor (View Source)

posted @ Tuesday, August 05, 2008 9:50 AM | Feedback (1)

With a new laptop there have been quite a few things I have had to configure again.  One of those is the default source view application related to Internet Explorer.  The following instructions apply to Windows XP (not sure yet on Vista).

I thought by changing the HTML Editor within IE (Tools - Internet Options - Programs) would have fixed the problem.  Nope, that did not work.  The following however does work nicely.

Run Regedit

HKEY_LOCAL_MACHINE
|- Software
|-- Microsoft
|--- Internet Explorer
|---- View Source Editor
|----- Editor Name (Default) = "C:\Program Files\TextPad 4\TextPad.exe"

If 'View Source Editor' doesn't exist you will need to create then create the key 'Editor Name' and set the value to the path to the editor that you are going to use.

I know other individuals like Notepad2 or SlickEdit

What editor's do you use?

category: Tools

Web Site Complete - Content Missing?

posted @ Sunday, July 13, 2008 9:44 PM | Feedback (0)

Ever have trouble getting content for web projects.  Pepi Ronalds wrote up a very nice article describing the pains related to getting content (type) for web related projects.  Check it out here.

Windows Vista Wallpapers – Nice collection

posted @ Saturday, July 12, 2008 9:19 PM | Feedback (0)

I came across this site this afternoon.  A number of beautiful photos by Harmad Darwish.  Harmad was hired by Microsoft to work on wallpaper collections for Vista.

image

category: Vista

Linq Samples Provided by MSDN Microsoft

posted @ Thursday, July 10, 2008 10:18 PM | Feedback (0)

In fact Microsoft has provided 101 of them.  How much do you wanna bet they are missing the one you are looking for?  (always 1 short).  Check it out here on MSDN

category: Linq

SQL Templates (in SQL Server Management Studio)

posted @ Tuesday, July 08, 2008 9:39 AM | Feedback (0)

Credit goes to the Cincinnati SQL Server User’s Group/Phil Japikse for the following tip.  Two things of interest in this post.  Ability to create Sql Templates within SQL Server Management Studio and SQL to find objects named like ‘%here%’ across all objects in a database.


USE <databasename,string,@p1>
GO
SELECT OBJECT_NAME(OBJECT_ID)
FROM sys.sql_modules
WHERE definition like '%<string_to_find,string,@p2>%'
 

Now that you have the SQL it is possible to create a SQL Template (View – SQL Templates) whereby you can simply select and push Ctrl-Shift-M for variable substitution.  Within the Template Window create a new folder to store your custom templates, create a new template, paste the above SQL and Save.  To use simply click on the template and Ctrl-Shift-M to be prompted for the variables and values.

Great stuff.  Thanks guys for the tip.

category: SQL Server

SubText Stuff to Know

posted @ Saturday, July 05, 2008 8:36 AM | Feedback (0)

Other Resources

category: SubText

Asp.net 2.0 Compilation Models

posted @ Saturday, July 05, 2008 8:29 AM | Feedback (0)

Keep the following in mind with 2.0 Asp.net applications

  • Visual Studio 2005/2008 knows nothing about compiling a web application.  Visual Studio lets the asp.net platform perform the compilation.
  • When you perform a VS.NET Build > VS.NET does not build the application, Asp.net performs the build build of all the .cs and .vb files.  The resulting assemblies are placed by default in the C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files directory.
  • The debug setting in the web.config (debug/release) controls the compilation mode.  If in debug mode then respective .pdb debugging symbol files are created.
  • The Configuration Manager in the default build model of Visual Studio is not utilized.  As a result the only option for a web site ‘project’ is the Debug compilation.  This is because the web.config controls the compilation.
  • The Publish command will precompile the web application and place the files in a directory for deployment.  The Publish command executes the command line aspnet_compiler tool with the appropriate switches.  Publish will always precompile a release build without debugging symbols (pdb files)
  • Note: the Publish command does not change the debug setting in the web.config.  The Publish command always compiles in release ode however if you precompile to an updateable web site and then update the web site in place those dynamic compilations will produce debug code and pdb files.

Using the Web Site Deployment Utility (WSD)

Using WSD the above scenario is different.  Web Site Deployment project is really a nice interface on a MSBuild project.  The deployment project creates a MSBuild file and passes it to aspnet_compiler for compilation.  Unlike the VS.NET Publish the WSD will update the web.config for the right compilation mode.  The user controls the compilation mode within the Configuration Manager when using the Web Site Deployment project.

Setting up Configuration Manager as follows will deploy the files to the directory highlighted below without debug symbols (debug=false).  By setting up the configuration as follows makes it easy to prepare for deployment.  Simply change the configuration mode and hit build.  As shown below it will simply prepare the application for build and asp_compiler will deploy to the selected directory. 

In addition to controlling the debug mode WSD is great for swapping out appsettings for different environments (i.e. stage/test/production) respective for each build.


 image 

Control the deployed directory via Properties of the WSD project.

image


By debug mode will look like the following.  Notice that I am not building the WSD project in this mode

image

More information and features of Web Site Deployment Project can be found here.

 

Additional Configuration of the MSBuild file

By selecting the deploy project in the Solution Explorer and selecting open you can add additional MSBuild commands to the xml document.  I often add the following so that only the most appropriate files are included in the Release directory.

<ItemGroup>
    <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.vshost.exe" />
    <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.sln" />
    <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.csproj" />
    <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.user" />
    <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*Copy of*" />
    <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.psd" />
    <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.cmd" />
    <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\obj\**\*.*" />
    <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.Publish.xml" />
    <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\test\**\*.*" />
    <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.aspx.resx" />
    <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.asax.resx" />
      <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.suo" />
  </ItemGroup>

 
 
    <Target Name="AfterBuild">
        <Delete Files="$(OutputPath)\PrecompiledApp.config"></Delete>
    </Target>
category: Asp.Net

New Blog Engine - Subtext

posted @ Thursday, July 03, 2008 9:26 AM | Feedback (0)

Yes, this is a new blog engine that I am taking for a test drive.  I tried BlogEngine.net for a few weeks but found just too many things that were causing problems and very little support for the problems I was having.  BE is currently at version 1.4.   I really like the ‘templating’ features of that engine and there are quite a few extensions already developed.  I think BE will grow to be very mature product but at this time just too many problems.

I really wanted a stable blog engine at this point.  Subtext setup was very easy and so far has been rock solid.  Good job with this.

 

My old blog at http://dyardy.spaces.live.com/ still lives for the time being as I make the transition.  Spaces is a great product but the time was right to get my blog back on my domain.  I have been using Spaces for 2.5 years and so I have many posts still on that engine.

Please update your RSS feeds to http://feeds.feedburner.com/davidyardy

category: SubText