Listing all Data Sources and their Dependencies (reports, items, etc) in SQL Server 2008 R2

The following (which was modified from what beargle posted earlier) does what I was looking for. This will list all the data sources by their actual name, and all their dependent items: SELECT C2.Name AS Data_Source_Name, C.Name AS Dependent_Item_Name, C.Path AS Dependent_Item_Path FROM ReportServer.dbo.DataSource AS DS INNER JOIN ReportServer.dbo.Catalog AS C ON DS.ItemID = C.ItemID … Read more

SQL Server stored procedure Nullable parameter

It looks like you’re passing in Null for every argument except for PropertyValueID and DropDownOptionID, right? I don’t think any of your IF statements will fire if only these two values are not-null. In short, I think you have a logic error. Other than that, I would suggest two things… First, instead of testing for … Read more

How to count total number of stored procedure and tables in SQL Server 2008

This will give you the count of tables and stored procedures. SELECT CASE TYPE WHEN ‘U’ THEN ‘User Defined Tables’ WHEN ‘S’ THEN ‘System Tables’ WHEN ‘IT’ THEN ‘Internal Tables’ WHEN ‘P’ THEN ‘Stored Procedures’ WHEN ‘PC’ THEN ‘CLR Stored Procedures’ WHEN ‘X’ THEN ‘Extended Stored Procedures’ END, COUNT(*) FROM SYS.OBJECTS WHERE TYPE IN (‘U’, … Read more

Stored Procedure parameter default value – is this a constant or a variable

It has to be a constant – the value has to be computable at the time that the procedure is created, and that one computation has to provide the value that will always be used. Look at the definition of sys.all_parameters: default_value sql_variant If has_default_value is 1, the value of this column is the value … Read more

Entity Framework Not Creating Database

Asked around on the MSDN forums instead, and got a satisfactory answer: Entity Framework will not create a database until first access. The current code block in Application_Start() only specifies the strategy to use when creating the database during first access. To trigger creation of the database on startup, an instance of the database context … Read more

Reset autoincrement in Microsoft SQL Server 2008 R2

If you use the DBCC CHECKIDENT command: DBCC CHECKIDENT (“YourTableNameHere”, RESEED, 1); But use with CAUTION! – this will just reset the IDENTITY to 1 – so your next inserts will get values 1, then 2, and then 3 –> and you’ll have a clash with your pre-existing value of 3 here! IDENTITY just dishes … Read more