Showing posts with label express. Show all posts
Showing posts with label express. Show all posts

Tuesday, March 20, 2012

Check for Null values in Transact Sql

I am using Visual Web Developer Express 2005 and SQL Server Express 2005.

I have set up a trigger that fires when an update has been performed on
a specific table. The trigger checks to see if specific columns have
been updated. If they have, then the trigger code is executed. This part
works fine.

I am now trying to find a way to check if null values exist in either
one of two field from the same table. If either field contains a null
value, then I don't want the trigger code to be executed.

How can I check for null values and skip a block of code within my
Transact Sql trigger.

Thanks....

You can use the IS NULL clause to test a column...

|||

Use something like:

if exists (select * from MyTbl where Col1 is null or Col2 is null)

//do not update

else //update

Thursday, March 8, 2012

Check connectivity Sql Server

Hello all, I am hoping this is the correct place for this. I have an application that depends on an active connection to Sql Server Express 2005. I am looking for a way is any to check for the existance ofthe server I defined and wether it is online or not. I know I can just catch the error on connection but it takes a bit and I have customers trying to cancel it before it's finished because they think it's locked up. I would like a quick way to check without trying to create a connection if it's online, then if it is, proceed, if not, let the customer know. I was hoping for something like a database server ping of sorts.

Thank you,

Jim

Still, the best/reliable way to check whether you can reach the server instance is connect to it. If you think the lock up time is too long considering that the server is down, you can adjust the connection timeout to be smaller than on-default value. There is caveat to this approach if your target machine is unreachable in the network, which may cause a single physical operation, tcp connection to take long time to finish.

Another way on top of my head is to check service manager of your targeted machine using console commmand "SC" and check the server status, an example is the following. The

>sc \\servername query mssqlserver

SERVICE_NAME: mssqlserver
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0

-HTH

Tuesday, February 14, 2012

character encoding problem

I'm storing data in SQL Server 2005 Express ntext fields. I've added <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> to the Master Page, but apostrophes and other characters are appearing incorrectly in the browser. For example, apostrophes are appearing as?. They seem to have changed to this when I upsized from Access to SQL Server (so I have? in the db field).

The back-end of the site is still in classic asp, where I can set the CodePage to 65001 and the CharSet to utf-8, and everything appears fine there. What can I change in the ASPX to get characters to display correctly?

Apostrophes in SQL Server falls under ANSI SQL 92 delimiters you have to take care of that in SQL Server and other characters fall under collation so it will help if you check both to see where the problem is coming from. The aspx pages falls under encoding in VS2005 you can use the advanced option to choose the editor to use to save your code that includes the code page and encoding. The links below will help you with delimiter and page level encoding in .NET. Hope this helps.

http://msdn2.microsoft.com/en-us/library/ms176027.aspx
http://www.yoda.arachsys.com/csharp/strings.html


|||

This conversion of apostrophes and other characters such as dashes took place when I used the upsizing wizard in Access. I thought the classic asp pages were somehow converting them and displaying them correctly. I was wrong - I had forgotten to change the connection string, so they were still connecting to the old Access dbEmbarrassed

For the sake of speed, I cobbled together a little VBScript and ran it against the SQL Server db to perform a quick find and replace.

|||So you have fixed the problem? if not let me know so we can find what needs to be fixed.