Showing posts with label SQL Server. Show all posts
Showing posts with label SQL Server. Show all posts
Thursday, November 5, 2009
Load a Xap file from Binary
Recently I was faced with a situation where I needed to load a .xap file from a database and preview the file using Silverlight. Typically, to display a Silverlight app hosted in a web site, one would use the
Thursday, April 30, 2009
Resolving Cannot generate SSPI context.
While there are some pretty complete explanations regarding this error (see links below), if you're looking for a post that forgoes the lengthy explanations and just gets to the good bits ...
You are out of luck on this one :)
That being said, I know that I would have benefited from someone mentioning some of the more basic places to look. In my team's case, the SQL Server account that our web app was using had the password expire on us. When we set up the account we inadvertently neglected to check off the bit about having the password never expire. In a production environment that's probably a good thing. But this is our test server.
Here are those helpful links I mentioned earlier:
How to troubleshoot the "Cannot generate SSPI context" error message
Cannot generate SSPI context” error message, when connect to local SQL Server outside domain
You are out of luck on this one :)
That being said, I know that I would have benefited from someone mentioning some of the more basic places to look. In my team's case, the SQL Server account that our web app was using had the password expire on us. When we set up the account we inadvertently neglected to check off the bit about having the password never expire. In a production environment that's probably a good thing. But this is our test server.
Here are those helpful links I mentioned earlier:
How to troubleshoot the "Cannot generate SSPI context" error message
Cannot generate SSPI context” error message, when connect to local SQL Server outside domain
Wednesday, November 12, 2008
PADR, PADL and PADC for SQL Server
Thanks to Igor Nikiforov for these very helpful UDFs. One of the biggest things I have on my wish list for SQL Server is more support for string functions. Here's the link...
UDFs PADL, PADC, PADR
UDFs PADL, PADC, PADR
Thursday, November 6, 2008
Avoid Inserting Duplicate Records
Here's a quick solution to the problem where you don't want to insert duplicate records into a SQL Server table. Of course, the easier way to do this is to set up a constraint, but there are times when you can't do that. For example, if you have a table where you are using a deleted flag as opposed to doing hard deletes. If you have foreign keys to deal with, I would suggest creating a table variable (again, assuming you are using SQL Server) and inserting the denormalized records there, and then doing the insert as listed below. You could probably do it in one statement, but just because you *can* do something doesn't necessarily mean you should. The two step process would be easier to read and more clearly indicates the intent of the code. Comments are great, but code should be self-documenting.
Hope this helps.
INSERT INTO TABLE_A
SELECT field_1, field_2, field_3
FROM TABLE_NEW_RECORDS B
WHERE NOT EXISTS
(
SELECT DISTINCT B.comp_1, B.comp_2, B.comp_3
FROM TABLE_LOOKUP LU
WHERE B.comp_1 = LU.comp_1 And
B.comp_2 = LU.comp_2 And
B.comp_3 = LU.comp_3
)
Hope this helps.
Subscribe to:
Posts (Atom)