I needed to parse a view definition and figure out the field mappings and underlying tables. Just some tricks along the way. I was using Sql Server 2008.
This will give you the entire view definition divided out into rows. Each row constitutes 255 chars
EXEC sp_helptext 'myViewName'
or
EXEC sp_help 'myViewName'
This gives you the entire view definition
select definition, *
from sys.objects o
join sys.sql_modules m on m.object_id = o.object_id
where o.object_id = object_id( 'myViewName')
and o.type = 'V'
Getting all the tables and fields that a view is dependant upon
sp_depends @objname = N'dbo.myViewName'
Getting the columns in the view in an easier consumable format
SELECT
*
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_NAME like ('%myViewName%')
ORDER BY
ORDINAL_POSITION ASC;
Thursday, January 23, 2014
Wednesday, January 22, 2014
Server 2012 Log Off
Tip of the Day-- go to the Start "screen", click on your user account picture/name in the upper-right hand corner of the screen, and select "Sign out". Or you can select "Switch User" from here.
To get to the "Start" menu hover the bottom right hand edge of the task bar and the "charms" should pop up--Start, Settings, etc...
This might be the first in a series of "How do I do what I use to do"
To get to the "Start" menu hover the bottom right hand edge of the task bar and the "charms" should pop up--Start, Settings, etc...
This might be the first in a series of "How do I do what I use to do"
Wednesday, January 8, 2014
Directory compares without installing a nifty little app
Here's the right way to do it, without the external downloads. It
looks like a lot at first, but once you've done it, it's very easy. It
works in all Windows versions from 7 back to 95. For our example assume
that you're comparing two directories named
'A' and 'B'.
1. run cmd.exe to get a command prompt. (In Windows 7, the powershell won't work for this, FYI.) Then do it again, so that you have two of them open next to each other.
2. in each window go to the directories that you want to compare. (Using 'cd' commands. If you're not comfortable with this, then you should probably go with the external utilities, unless you want to learn command prompt stuff.)
3. type 'dir /b > A.txt' into one window and 'dir /b > B.txt' into the other. You'll now have two text files that list the contents of each directory. The /b flag means bare, which strips the directory listing down to file names only.
4. move B.txt into the same folder as A.txt.
5. type 'fc A.txt B.txt'. The command 'fc' means file compare. This will spit out a list of the differences between the two files, with an extra line of text above and below each difference, so you know where they are. For more options on how the output is formatted, type 'fc /?' at the prompt. You can also pipe the differences into another file by using something like 'fc A.txt B.txt > differences.txt'.
use dir /s/b to include the subdirectories
1. run cmd.exe to get a command prompt. (In Windows 7, the powershell won't work for this, FYI.) Then do it again, so that you have two of them open next to each other.
2. in each window go to the directories that you want to compare. (Using 'cd' commands. If you're not comfortable with this, then you should probably go with the external utilities, unless you want to learn command prompt stuff.)
3. type 'dir /b > A.txt' into one window and 'dir /b > B.txt' into the other. You'll now have two text files that list the contents of each directory. The /b flag means bare, which strips the directory listing down to file names only.
4. move B.txt into the same folder as A.txt.
5. type 'fc A.txt B.txt'. The command 'fc' means file compare. This will spit out a list of the differences between the two files, with an extra line of text above and below each difference, so you know where they are. For more options on how the output is formatted, type 'fc /?' at the prompt. You can also pipe the differences into another file by using something like 'fc A.txt B.txt > differences.txt'.
use dir /s/b to include the subdirectories
Useless or fun and useful? Make windows minimize
Win7
Another *neat* little trick is if you want to ONLY show one window on your screen and minimize everything else, just grab the title bar with your mouse and SHAKE THE WINDOW REALLY HARD. Everything but the window you're holding on to will minimize. To bring everything back up, just shake your single Explorer window again and it all restores.
Another *neat* little trick is if you want to ONLY show one window on your screen and minimize everything else, just grab the title bar with your mouse and SHAKE THE WINDOW REALLY HARD. Everything but the window you're holding on to will minimize. To bring everything back up, just shake your single Explorer window again and it all restores.
Thursday, July 18, 2013
Tip and Tricks of C#
Was looking for a couple of syntactical explanations and ran across this post. Awesome.
Tricks and Tips
Just handy reference ('cause you don't always know what to google on)
Syntax
Tricks and Tips
Just handy reference ('cause you don't always know what to google on)
Syntax
Thursday, February 21, 2013
xml handy items
I do a lot of processing of XML documents from various sources. Just a couple of items I want to have around even through they are in my library of tricks. Removes declaration from XML document so that it can be loaded into XDocument.
private Regex M_RemoveDecl = new Regex(@"<\?xml.*?\?>");
This is to remove namespaces in documents. Makes the query of the document easier.
... Taken from this discussion
public static string RemoveAllNamespaces(string xmlDocument) { XElement xmlDocumentWithoutNs = RemoveAllNamespaces(XElement.Parse(xmlDocument)); return xmlDocumentWithoutNs.ToString(); } private static XElement RemoveAllNamespaces(XElement xmlDocument) { if (!xmlDocument.HasElements) { XElement xElement = new XElement(xmlDocument.Name.LocalName); xElement.Value = xmlDocument.Value; foreach (XAttribute attribute in xmlDocument.Attributes()) xElement.Add(attribute); return xElement; } return new XElement(xmlDocument.Name.LocalName, xmlDocument.Elements().Select(el => RemoveAllNamespaces(el))); }
private Regex M_RemoveDecl = new Regex(@"<\?xml.*?\?>");
This is to remove namespaces in documents. Makes the query of the document easier.
public static string RemoveAllNamespaces(string xmlDocument) { XElement xmlDocumentWithoutNs = RemoveAllNamespaces(XElement.Parse(xmlDocument)); return xmlDocumentWithoutNs.ToString(); } private static XElement RemoveAllNamespaces(XElement xmlDocument) { if (!xmlDocument.HasElements) { XElement xElement = new XElement(xmlDocument.Name.LocalName); xElement.Value = xmlDocument.Value; foreach (XAttribute attribute in xmlDocument.Attributes()) xElement.Add(attribute); return xElement; } return new XElement(xmlDocument.Name.LocalName, xmlDocument.Elements().Select(el => RemoveAllNamespaces(el))); }
Wednesday, February 20, 2013
Updating ReportViewer to VS2010
OK, today I blew the dust off of a project that had ReportView 9.0. Since I had coded that website many moons have pasted and we have upgraded to VS2010.
I tried to just stay on RV9 however, one of the reports was erroring and I had javascript issues with the handler page that it inserts.
So, upgrade I did and not without google's help!
I had a report that was cause compile errors (The processing of Parent for the tablix ‘table1’ cannot be performed) with the grouping. I had to take out the "parent" tag and then all was well. Basically old versions glossed over this mishap, but not version 10. For the long explanation of why you need to do this, go here.
OrderNumGrp
">
<GroupExpressions>
<GroupExpression>=Fields!ClientOrderNum.Value</GroupExpression>
</GroupExpressions>
=Fields!ClosedDate.Value
Finally, when you are deploying to a server with IIS7. Make sure that you add the following to your web.config
webServer
>
...
ReportViewerWebControlHandler
" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
...
webServer>
Finally, as it always happends, when you get it onto the production server something else goes wrong. I was getting this error
Compiler Error Message: CS0433: The type 'Microsoft.Reporting.WebForms.ReportDataSource' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\8.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' and 'c:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll'
If you add the following to your web.config it tells .net to always direct to the new version
publicKeyToken="b03f5f7f11d50a3a" />
newVersion="10.0.0.0"/>
Happy Reporting
I tried to just stay on RV9 however, one of the reports was erroring and I had javascript issues with the handler page that it inserts.
So, upgrade I did and not without google's help!
- Install on your machine ReportViewer 10
- change the references in your project to point to version 10 of Microsoft.ReportViewer.Common and Microsoft.ReportViewer.WebForms
- If you registered your control, change this tag in your .aspx or control
- <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0...
I had a report that was cause compile errors (The processing of Parent for the tablix ‘table1’ cannot be performed) with the grouping. I had to take out the "parent" tag and then all was well. Basically old versions glossed over this mishap, but not version 10. For the long explanation of why you need to do this, go here.
">
<GroupExpressions>
<GroupExpression>=Fields!ClientOrderNum.Value</GroupExpression>
</GroupExpressions>
Finally, when you are deploying to a server with IIS7. Make sure that you add the following to your web.config
>
...
" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
...
webServer>
Finally, as it always happends, when you get it onto the production server something else goes wrong. I was getting this error
Compiler Error Message: CS0433: The type 'Microsoft.Reporting.WebForms.ReportDataSource' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\8.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' and 'c:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll'
If you add the following to your web.config it tells .net to always direct to the new version
Happy Reporting
Subscribe to:
Posts (Atom)