Tuesday, March 31, 2015

Write Less Code With PowerShell Parameter Validation

You’ll often write a script or function that needs to accept some kind of input. This could be a computer name, a file path or anything like that. You can tell Windows PowerShell to expect these parameters, collect them from the command line, and put their values into variables within your script or function. That makes dealing with input easy and efficient.
You just have to know how to declare your parameters. The simplest means of doing so is the param block:
Param(
  [string]$computerName,
  [string]$filePath
)
You don’t have to break that down into separate lines like I’ve done. It’s legal to run it all together on a single line. I prefer to break it down for easier reading, though. 

That way, my parameters are consistent with what’s already in the shell.
If I put this into a script named Get-Something.ps1, I’d use the parameters like this:
./Get-Something –computerName SERVER1 –filePath C:\Whatever
I could also truncate the parameter names. This lets me type fewer characters and they still work:
./Get-Something –comp SERVER1 –file C:\Whatever
I could even omit the names entirely. Windows PowerShell will automatically and positionally accept values. Here I need to be careful to provide values in the same order in which the parameters are listed in my file:
./Get-Something SERVER1 C:\Whatever
Of course, by using parameter names, the command becomes a bit easier for a person to figure out. I then get the luxury of putting the parameters in any order I want:
./Get-Something –filePath C:\Whatever –computerName SERVER1
Windows PowerShell also provides a more complex way of declaring parameters. This more full-fledged syntax lets you define parameters as mandatory, specify a position (if you don’t do so, then the parameter can only be used by name) and more. This expanded syntax is also legal in both scripts and functions:
[CmdletBinding()]
Param(
  [Parameter(Mandatory=$True,Position=1)]
   [string]$computerName,
 
   [Parameter(Mandatory=$True)]
   [string]$filePath
)
Again, you can run all that together on a single line, but breaking it down makes it a bit easier to read. I’ve given both of my parameters a [Parameter()] decorator, and defined them both as mandatory.
If someone tries to run my script and forgets one or both of these parameters, the shell will prompt for them automatically. There’s no extra work on my part needed to make that happen. I’ve also defined –computerName as being in the first position, but –filePath needs to be provided by name.
There are some other advantages to using the [CmdletBinding()] directive. For one, it ensures my script or function will have all the Windows PowerShell common parameters, including –Verbose and –Debug. Now, I can use Write-Verbose and Write-Debug within my script or function, and their output will be suppressed automatically.
Run the script or function with –Verbose or –Debug, and Write-Verbose or Write-Debug (respectively) are magically activated. That’s a great way to produce step-by-step progress information (Write-Verbose) or add debugging breakpoints (Write-Debug) in your scripts.
As they’re currently written, both parameters will accept only a single value. Declaring them as [string[]] would let them accept an entire collection of values. You’d then enumerate this using a Foreach loop, so you could work with one value at a time.
Another neat parameter type is [switch]:
Param([switch]$DoSomething)
Now, I can run my script or function with no –DoSomething parameter and internally the $DoSomething variable will be $False. If I run the script with the –DoSomething parameter, $DoSomething gets set to $True. There’s no need to pass a value to the parameter. Windows PowerShell sets it to $True if you simply include it. This is how switch parameters operate, such as the –recurse parameter of Get-ChildItem.
Keep in mind that each parameter is its own entity, and it’s separated from the next parameter by a comma. You’ll notice that in a previous example:
[CmdletBinding()]
Param(
  [Parameter(Mandatory=$True,Position=1)]
   [string]$computerName,
 
   [Parameter(Mandatory=$True)]
   [string]$filePath
)
There the entire –computerName parameter, including its [Parameter()] decorator, appears before the comma. The comma indicates I’m done explaining the first parameter and I’m ready to move on to the next. Everything associated with –filePath follows the comma. If I needed a third parameter, I’d put another comma:
[CmdletBinding()]
Param(
  [Parameter(Mandatory=$True,Position=1)]
   [string]$computerName,
 
   [Parameter(Mandatory=$True)]
   [string]$filePath,

   [switch]$DoSomething
)
All of that is contained within the Param() block. Note that you don’t have to use the [Parameter()] decorator on every parameter. Only use it on the ones where you need to declare something, such as the parameter being mandatory, accepting pipeline input, being in a certain position and so on. Run help about_functions_advanced_parameters in Windows PowerShell for more information on other attributes you can declare that way.
Writing functions and scripts that accept input only via parameters is a best practice. It makes them more self-contained, easier to document and more consistent with the way the rest of the shell works.

Monday, March 23, 2015

How to fix SharePoint 2013 Web Application error “The context has expired and can no longer be used”


Today, I came across this odd error quite weired, after some research I found the folowwing solution.

Here is a quick guide that might help you get rid of it.

If you see this error after opening your SharePoint 2013 site, there is a lack of synchronization between Date and Time settings in your SharePoint 2013 Server and your SharePoint web application.
Sorry, something went wrong. The context has expired and can no longer be used. (Exception from HRESULT: 0x80090317)
Here is how you fix it!
  • Open Central Administration -> Application Management.
  • Locate the relevant Web Application and click on 
  • Web Application General Setting window will open up, notice that theDefault Time Zone is missing.

  • Open Date and Time options on your server and check which time zone is configured. Configure the same time zone in Web Application General Setting.
  • Perform IIS Reset and open your SharePoint 2013 site again.
Hooray! SharePoint site works again!
I have to thank Alex Entrekin who helped me.
Cheers,

Thursday, March 19, 2015

Export & Import Hyper-V Virtual machines with snapshots

Here is a straithforward article about import/export Hyper-V virtual machines with snapshots.
Before I get going I want to get this out of the way:  Export / import in Hyper-V is by no means intuitive or easy to use.  It is definitely something that I hope we can improve in a future release - but for this release it is functional.
So with that behind us, let's start pulling this apart.
If you want to move or copy a virtual machine with Hyper-V, then you will need to use the export / import functionality provided by Hyper-V. 
The first thing you need to do is to pick the virtual machine that you want to copy and / or move, and then select Export...from the action menu / pane.  You will be presented with the following dialog:
export
Today I will be looking at the case where you specify an export path (in my case: "C:\Export") but do not check the option toExport only the virtual machine configuration.
Before going further I need to cover virtual machine names and IDs.  Each Hyper-V virtual machine has one of each of these.

The virtual machine name is what you called the virtual machine.  For today's post I am using a virtual machine with a name of "Test Export VM".  While you are likely to give each of your virtual machines different names - the virtual machine name is not required to be unique.

The virtual machine ID is a GUID that Hyper-V generates automatically for each virtual machine.  This ID is used to uniquely identify one virtual machine from another.  For the most part the virtual machine ID is never displayed in the Hyper-V user interface (with the exception of error messages).  The virtual machine I am using for today's post has a virtual machine ID of "6D59FE56-6D20-4129-9BF3-2457DDB58A9A".

Beyond this, each snapshot that a virtual machine has has its own name and ID.
Hitting Export will result in Hyper-V copying everything that makes up the selected virtual machine into a new folder under the export path you specify.  This new folder will be named after the virtual machine name (in my case: "C:\export\Test Export VM").  Under this new directory will be the following items:
  • The Virtual Machines folder

    • This folder will contain a single .exp file, which will use the virtual machine ID for its name (in my case: "6D59FE56-6D20-4129-9BF3-2457DDB58A9A.exp").  The .exp file is the exported configuration of the virtual machine. 

      There will also be another folder in this folder, which is also named use the virtual machine ID.  If the virtual machine was in a saved state when it was exported this sub-folder will contain two saved state files (a .vsv and a .bin file), otherwise it will be empty.
  • The Virtual Hard Disks folder

    • This folder contains copies of each of the virtual hard disks associated with the virtual machine.  Note that if you have two virtual hard disks with the same name (but different locations) associated with a virtual machine, exporting the virtual machine will fail.
  • The Snapshots folder

    • This folder will contain:
      • A .exp file for each snapshot the virtual machine had (name after the snapshot ID)
      • A folder named after the snapshot ID that contains the saved state files for the snapshot in question.
      • A folder named after the virtual machine ID that will contain the differencing disks used by all of the snapshots associated with the virtual machine (.avhd files).
  • config.xml

    • I will look at this file in more detail another day.  It is not necessary for standard export / import usage.
You can freely move / copy / backup this entire directory structure now.  When you are ready to import the virtual machine you will need to go the the Hyper-V Manager and select Import Virtual Machine... from the action menu / pane.  You will see:
import
Before clicking Import there are three important things to know:
  • You need to specify the folder that was created during export, not the folder that was used for export.  So in my case I need to specify "C:\Export\Test Export VM" instead of "C:\Export".
  • When you import a virtual machine it will be left in its current directory (in my case "C:\Export\Test Export VM") and it will be impossible to move the virtual machine after import.  So make sure that you move the exported virtual machine to your desired location before you import it.
  • Importing a virtual machine deletes the .exp files, which stops you from importing it again.  If you want to use an exported virtual machine as a backup / template that you will import multiple times - you need to make a copy of it before importing it.
After you click Import the file structure of the exported virtual machine will remain roughly the same, with the following exceptions:
  • The .exp files will be deleted and will be replaced with .xml configuration files.
  • The config.xml file will be deleted.
And now the virtual machine will appear under the Hyper-V manager and you will be able to interact with it directly.
Cheers,

Source : http://blogs.msdn.com/b/virtual_pc_guy/archive/2008/08/26/hyper-v-export-import-part-1.aspx

Monday, February 2, 2015

Casablanca SharePoint Days 2015: The FIRST Event!

The 28 and 29 of last January, the real "First" SharePoint Event took place in Technopark, Casablanca. I’m talking about the Casablanca SharePoint Days 2015.

During two days (yah! Quite short), 20 Experts Microsoft MVPs were giving conferences around SharePoint technologies, best practices and recent improvements…

I had the chance to take part to this event, really I couldn’t miss itJ

I had the pleasure to meet the most valuables professionals, those who share for the passion of the technology, who give of their time to help and rescue other members in the community.

I have the pleasure to meet great MVPs like:
ü  Guillaume Meyer
ü  Nicolas Georgeault
ü  Patrick Guimonet
ü  Isabelle Van Campenhoudt 
ü  Serge Tremblay
ü  Gokan Ozcifci
ü  Michael Noel

, who I thanks again for their effort and commitment. 




Tuesday, November 11, 2014

SQL Server 2014 Express Actual Memory Limit

SQL Server 2014 Express Actual Memory Limit

 In this post I'm gonna share a very intersting discovery That i just realise once working with a new installation for demo of SQL Express 2014.

The official SQL Server 2014 Express edition memory limit is 1GB per instance – that is, strictly speaking, the buffer cache restriction. In 2010, the SQL Server MVP Pawel Potasinski confirmed that SQL Server 2008 R2 Express edition, which has the same 1GB memory limit, can actually use about 1400MB of memory. His post is in Polish, so you might have to use Google translate, but the script that he uses and the results are easy to interpret.
In a similar way the SQL Server Pro Kevin Kline confirmed that SQL Server 2012 Express Edition memory working set size can grow around 1.4-1.5GB.
Naturally, with the release of SQL Server 2014 Express edition, it is interesting to check what is the actual memory limit. We’ve used the same script that Kevin Kline posted on his blog:


SELECT

 CASE

 WHEN database_id = 32767 THEN 'mssqlsystemresource'

 ELSE DB_NAME(database_id)

 END AS [Database],

 CONVERT(numeric(38,2),(8.0 / 1024) * COUNT(*)) AS [MB in buffer cache]

FROM sys.dm_os_buffer_descriptors

GROUP BY database_id

ORDER BY 2 DESC;

GO
-- Assess amount of tables resident in buffer cache

SELECT

 QUOTENAME(OBJECT_SCHEMA_NAME(p.object_id)) + '.' +

 QUOTENAME(OBJECT_NAME(p.object_id)) AS [Object],

 CONVERT(numeric(38,2),(8.0 / 1024) * COUNT(*)) AS [MB In buffer cache]

FROM sys.dm_os_buffer_descriptors AS d

 INNER JOIN sys.allocation_units AS u ON d.allocation_unit_id = u.allocation_unit_id

 INNER JOIN sys.partitions AS p ON (u.type IN (1,3) AND u.container_id = p.hobt_id) OR (u.type = 2 AND u.container_id = p.partition_id)

WHERE d.database_id = DB_ID()

GROUP BY QUOTENAME(OBJECT_SCHEMA_NAME(p.object_id)) + '.' + QUOTENAME(OBJECT_NAME(p.object_id))

ORDER BY [Object] DESC;

GO
-- Fill up Express Edition's buffer allocation

IF OBJECT_ID(N'dbo.test', N'U') IS NOT NULL

 DROP TABLE dbo.test;

GO
CREATE TABLE dbo.test (col_a char(8000));

GO
INSERT INTO dbo.test (col_a)

 SELECT REPLICATE('col_a', 8000)

 FROM sys.all_objects

 WHERE is_ms_shipped = 1;
CHECKPOINT;

GO 100
select scheduler_id,cpu_id, status, is_online from sys.dm_os_schedulers where status='VISIBLE ONLINE'
select cpu_count from sys.dm_os_sys_info

You can download the scriptSQL-Test.txt SQl Server 2014 Express Memory Limit that we are using in the demo.
Thanks to NetoMeter Blog for their share.

Wednesday, November 5, 2014

How to determine if you are using SharePoint 2007, 2010, and 2013

SharePoint Tips and Tricks

Today I m gonna share with you, dear readers a new trick even generally tought as a basic one:)
What may seem obvious is actually more difficult to determine than you’d expect. Finding your version will depend on what operating system SharePoint is installed on and what build you are running, plus they all store the version information in separate places.
There are three places you can check for the version number: Control Panel Program and Features or Add and Remove ProgramsCentral Administration, or PowerShell. Not all of these will work depending on the SharePoint build, but one will certainly work for your environment.
Most of these examples will get you a build number and that build number will have to be looked up.  At the bottom of the article is a list of build numbers and what version and patch level they relate to.

What version of Microsoft SharePoint 2007 you are running? MOSS or WSS?

Microsoft SharePoint 2007 comes in two main version MOSS or WSS3.0 (Microsoft Office SharePoint Server or Windows SharePoint Services 3.0), and there are two versions of MOSS: SharePoint Standard and SharePoint Enterprise.
Using Windows Server 2008 Programs and Features: On Windows Server 2008, go to Control Panel and click Programs and Features.  On the left side, select View Installed Updates.
Windows Server 2008 Installed Updates
Using Windows Server 2003 Add/Remove Programs: On Windows Server 2003, go to Control Panel then click Add or Remove Programs and check Show Updates.
Windows Server 2003 Installed Updates

Using Central Administration to Find Your SharePoint Version

Go to Central Administration and click Site Actions then click Site Settings. In the Site Information box is the version, take that and look up what patch level you are at (found at the bottom of this article).
SharePoint Central Administration Site Settings

Are You Using the Standard or Enterprise version of MOSS?

Go to the Central Administration and click Operations then click Enable Enterprise Features. For Enterprise edition, the radio button will be disabled, otherwise it is Standard edition. This version pictured below is Enterprise.  This is another roundabout way of telling if you have MOSS or WSS3.0 because WSS3.0 will nothave the Enable Enterprise Feature under the Operations category.
SharePoint Central Administration Enable Enterprise features

Are You Running SharePoint 2010 Version or SharePoint 2013 Version?

Microsoft SharePoint comes in two main flavors: Microsoft SharePoint Server and Microsoft SharePoint Foundation both have similar ways of determining what version you’re running. The easiest way to determine what version you have is to access to the server. From the server, you can use Central Administration’s Check Product and Patch Installation Status or the PowerShell.

Using the Central Administration Method:

Go to Central Administration and click Upgrade and Migration then click Check Product and Patch installation Status.

Microsoft SharePoint Server 2010

Microsoft SharePoint Server 2010

Microsoft SharePoint Foundation 2010

Microsoft SharePoint Foundation 2010

Microsoft SharePoint Server 2013

Microsoft SharePoint Server 2013

Microsoft SharePoint Foundation 2013

Microsoft SharePoint Foundation 2013

Using the PowerShell Method:

This command works in both SharePoint 2013 and 2010.  You will need to run this in the SharePoint Management PowerShell:
(get-spfarm).BuildVersion
SharePoint Management PowerShell
You will need to take the value it returns and look up what it returns and match it with the numbers found below (I recommend just hitting CTL F and copy/pasting your number in to find it faster):

WSS 3.0 and MOSS 2007

  • 12.0.0.6679    WSS 3.0 or MOSS 2007 SP3  + June 2013 cumulative Update
  • 12.0.0.6676    WSS 3.0 or MOSS 2007 SP3  + April 2013 cumulative Update
  • 12.0.0.6673    WSS 3.0 or MOSS 2007 SP3  + February 2013 cumulative Update
  • 12.0.0.6670    WSS 3.0 or MOSS 2007 SP3  + December 2012 cumulative Update
  • 12.0.0.6668    WSS 3.0 or MOSS 2007 SP3  + October 2012 cumulative Update
  • 12.0.0.6665    WSS 3.0 or MOSS 2007 SP3  + August 2012 cumulative Update
  • 12.0.0.6662    WSS 3.0 or MOSS 2007 SP3  + June 2012 cumulative Update
  • 12.0.0.6661    WSS 3.0 or MOSS 2007 SP3  + April 2012 cumulative Update
  • 12.0.0.6658    WSS 3.0 or MOSS 2007 SP3  + February 2012 cumulative Update
  • 12.0.0.6656    WSS 3.0 or MOSS 2007 SP3  + December 11 cumulative Update
  • 12.0.0.6654    WSS 3.0 or MOSS 2007 SP3  + October 11 cumulative Update
  • 12.0.0.6606    WSS 3.0 or MOSS 2007 SP3
  • 12.0.0.6565    WSS 3.0 or MOSS 2007 SP2  + August 11 cumulative Update
  • 12.0.0.6562    WSS 3.0 or MOSS 2007 SP2  + June 11 cumulative Update
  • 12.0.0.6557    WSS 3.0 or MOSS 2007 SP2  + Apr 11 cumulative Update
  • 12.0.0.6554    WSS 3.0 or MOSS 2007 SP2  + Feb 11 cumulative Update
  • 12.0.0.6550    WSS 3.0 or MOSS 2007 SP2  + Dec 10 cumulative Update
  • 12.0.0.6548    WSS 3.0 or MOSS 2007 SP2  + Oct 10 cumulative Update
  • 12.0.0.6545    WSS 3.0 or MOSS 2007 SP2  + Aug 10 cumulative Update
  • 12.0.0.6539    WSS 3.0 or MOSS 2007 SP2  + June 10 cumulative Update
  • 12.0.0.6535    WSS 3.0 or MOSS 2007 SP2  + April 10 cumulative Update
  • 12.0.0.6529    WSS 3.0 or MOSS 2007 SP2  + February 10 cumulative Update
  • 12.0.0.6524    WSS 3.0 or MOSS 2007 SP2  + December 09 cumulative Update
  • 12.0.0.6520    WSS 3.0 or MOSS 2007 SP2  + October 09 cumulative Update
  • 12.0.0.6514    WSS 3.0 or MOSS 2007 SP2  + August 09 cumulative Update
  • 12.0.0.6510    WSS 3.0 or MOSS 2007 SP2  + June 09 cumulative Update
  • 12.0.0.6504    WSS 3.0 or MOSS 2007 SP2  + April 09 cumulative Update

SharePoint Foundation 2010

  • RTM                       14.0.4762.1000
  • June 2010 CU     14.0.5114.5003
  • June 2010 CU     14.0.5114.5000
  • Aug 2010 CU       14.0.5123.5000
  • Oct 2010 CU        14.0.5128.5000
  • Dec 2010 CU       14.0.5130.5002
  • Feb 2011 CU       14.0.5136.5002
  • April 2011 CU     14.0.5138.5001
  • Service Pack 1    14.0.6029.1000
  • June 2011 CU     14.0.6106.5000
  • June 2011 CU     14.0.6106.5002
  • Aug 2011 CU       14.0.6109.5002
  • Oct 2011 CU        14.0.6112.5000
  • Dec 2011 CU       14.0.6114.5000
  • Feb 2012 CU       14.0.6117.5002
  • April 2012 CU     14.0.6120.5000
  • April 2012 CU     14.0.6120.5006
  • June 2012 CU     14.0.6123.5002
  • August 2012 CU                14.0.6126.5000
  • October 2012 CU              14.0.6129.5000
  • December 2012 CU         14.0.6131.5001

Microsoft SharePoint Server 2010

  • RTM                       14.0.4762.1000
  • June 2010 CU     14.0.5114.5003
  • Aug 2010 CU       14.0.5123.5000
  • Oct 2010 CU        14.0.5128.2003
  • Dec 2010 CU       14.0.5130.5002
  • Feb 2011 CU       14.0.5136.5002
  • April 2011 CU     14.0.5138.5001
  • Service Pack 1    14.0.6029.1000
  • June 2011 CU     14.0.6106.5000
  • June 2011 CU     14.0.6106.5002
  • Aug 2011 CU       14.0.6109.5002
  • Oct 2011 CU        14.0.6112.5000
  • Dec 2011 CU       14.0.6114.5000
  • Feb 2012 CU       14.0.6117.5002
  • April 2012 CU     14.0.6120.5000
  • April 2012 CU     14.0.6120.5006
  • June 2012 CU     14.0.6123.5002
  • August 2012 CU                14.0.6126.5000
  • October 2012 CU              14.0.6129.5003
  • December 2012 CU         14.0.6131.5003

SharePoint Server and Foundation 2013

    • 15.0.4517             June 2013 CU
    • 15.0.4505             April 2013 CU
    • 15.0.4481             March Update
    • ​ 15.0.4420            RTM
  • Orginal author: 

Sunday, October 26, 2014

Comparison of SQL Server Compact, SQLite, SQL Server Express and LocalDB

In his article I'm gonna share with you an article of ErikEJ concerning the difference between SQL Server Compact, SQLite, SQL Server Express and LocalDB


Now that SQL Server 2014 and SQL Server Compact 4 has been released, some developers are curious about the differences between SQL Server Compact 4.0 and SQL Server Express 2014 (including LocalDB)

I have updated the comparison table from the excellent discussion of the differences between Compact 3.5 and Express 2005 here to reflect the changes in the newer versions of each product.
Information about LocalDB comes from here and SQL Server 2014 Books Online. LocalDB is the full SQL Server Express engine, but invoked directly from the client provider. It is a replacement of the current “User Instance” feature in SQL Server Express.
FeatureSQL Server Compact 3.5 SP2SQL Server Compact 4.0SQLite, incl SQLite ADO.NET ProviderSQL Server
Express 2012
SQL Server 2012 LocalDB
Deployment/ Installation Features     
Installation size2.5 MB download size
12 MB expanded on disk
2.5 MB download size
18 MB expanded on disk
10 MB download, 14 MB expanded on disk120 MB download size
> 300 MB expanded on disk
32 MB download size
> 160 MB on disk
ClickOnce deployment
Yes
Yes
Yes
Yes
Yes
Privately installed, embedded, with the applicationYesYesYesNoNo
Non-admin installation optionYesYesYesNoNo
Runs under ASP.NETNoYesYesYesYes
Runs on Windows Mobile / Windows Phone platformYesNoYesNoNo
Runs on WinRT (Phone/Store Apps)NoNoYesNoNo
Runs on non-Microsoft platformsNoNoYesNoNo
Installed centrally with an MSIYesYesYesYesYes
Runs in-process with applicationYesYesYesNoNo (as process started by app)
64-bit supportYesYesYesYesYes
Runs as a serviceNo – In process with applicationNo - In process with applicationNo - In process with applicationYesNo – as launched process
Data file features     
File formatSingle fileSingle fileSingle fileMultiple filesMultiple files
Data file storage on a network shareNoNoNoNoNo
Support for different file extensionsYesYesYesNoNo
Database size support4 GB4 GB140 TB10 GB10 GB
XML storageYes – stored as ntextYes - stored as ntextYes, stored as textYes, nativeYes, native
Binary (BLOB) storageYes – stored as imageYes - stored as imageYesYesYes
FILESTREAM supportNoNoNoYesNo
Code free, document safe, file formatYesYesYesNoNo
Programmability     
Transact-SQL - Common Query FeaturesYesYesNoYesYes
Procedural T-SQL - Select Case, If, featuresNoNoLimitedYesYes
Remote Data Access (RDA)YesNo (not supported)NoNoNo
ADO.NET Sync FrameworkYesNoNoYesYes
LINQ to SQLYesNo (not supported)NoYesYes
ADO.NET Entity Framework 4.1Yes (no Code First)YesYesYesYes
ADO.NET Entity Framework 6Yes (fully)Yes (fully)Yes (limited)YesYes
Subscriber for merge replicationYesNoNoYesNo
Simple transactionsYesYesYesYesYes
Distributed transactionsNoNoNoYesYes
Native XML, XQuery/XPathNoNoNoYesYes
Stored procedures, views, triggersNoNoViews and triggersYesYes
Role-based securityNoNoNoYesYes
Number of concurrent connections256 (100)256UnlimitedUnlimitedUnlimited (but only local)
There is also a table here that allows you to determine which Transact-SQL commands, features, and data types are supported by SQL Server Compact 3.5 (which are the same a 4.0 with very few exceptions), compared with SQL Server 2005 and 2008.