sql-server

TransactionScope with IsolationLevel set to Serializable is locking all SQL SELECTs

I'm using PowerShell transactions; which create a CommittableTransaction with an IsolationLevel of Serializable. The problem is that when I am executing a Transaction in this context all SELECTs are blocked on the tables affected by the transaction on any connection besides the one executing the transaction. I can perform gets from withi...

Filter list by custom code in Reporting Services 2005?

Can you do this? The list filter I want to use looks like this: Expression Operator Value =Code.GetOccCat(Fields!accountnumber.Value) = =1 No dice. Basically, it acts like that function returns null as far as the filter is concerned, but when I take the filter off and put the exact...

INSERT Xml into SQL Server 2008 database

Hello I'm trying to insert some XML data into a table on SQL Server 2008. However I keep getting thrown this error; XML parsing: line 1, character 39, unable to switch the encoding The database column filemeta uses the XML datatype, and I've switch the encoding to UTF-16 which I believe is necessary for adding XML data. INSERT IN...

SQL Server 2008 permission for View Dependencies

I would like to enable a SQL server user with read-only access to a DB the ability to view object dependencies. As a sysadmin I can select a table in SSMS and view any dependent objects (views, SPROCs, etc). My read-only users can see very few or none of these dependencies. I have already granted view definition but that didn't do it. D...

How to store query execution plan so that they can be used later

My applications runs queries against a sql server database. In many cases I can see the benefit of an execution plan: for example I click for the first time on a button to SELECT * from Tasks WHERE IdUser = 24 AND DATE < '12/12/2010' and DATE > '01/01/2010' it takes 15 seconds the first time, 8 seconds the following times. EDIT: ...

Creating DataBase (mdf) from DataSet

I have a DataSet consistint of a big number of tables of information. Is it possible automaticly create SQL Server DataBase (mdf-file) from description of my DataSet? Of course, I can do it manually, but may be there is a better way? ...

How i to get the exact match join for the below scenario?

How do i join the below tables TableA TableB TableC TableD ID ID_C ID ID_A Value ID ID ID_C Value 1 1 1 1 a 1 1 1 a 2 1 b 2 1 b in order to get the Result like Result ID ID_B Value ID_C ID_D ...

multiple GROUP BY columns into one column

Products are grouped for inspected and pass/fail on about 20 criteria. They want a report that counts how many of each defect an individual group has. Defect* is varchar(3) and is used to identify which criteria failed. The table has 3 columns for defects and I can return them with something like: SELECT GroupID, Defect1, COUNT(...

Complicated daily automatic insert query in 2 tables

I have the following tables with their columns (only the relevant columns are listed): Entry EntryID (int/auto-inc) EmployeeNumber (int) JustifyDate (datetime) EntryDate (datetime) Employee EmployeeNumber (int) CoreHourID (int) WorkingFromHome (bit/bool) Hour EntryID (int) InHour (datetime) OutHour (...

Can't connect to SQL Server 2008 from .NET 3.5

I installed SQL Server 2008 Management Studio, and uninstalled 2005 as a consequence my .net application with a local SQL Server express doesn’t work anymore. I tried with nothwind 2008 sample at my App_Data folder. The connection string is : Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\NORTHWND.MDF;Integrated Security=Tr...

How to store and extract XML information from an nvarchar(max) type column, and use it in joins?

Hi, I have a column of type 'nvarchar(max)' that should now hold XML information instead of just a string. Say: col1 has value 'abc' Now it has values, with additional info: <el1>abc</el2> <el2>someotherinfo</el2> Storing the information to the column is fine, since it can still be pushed in as a string. However, extracting the same...

Which query seems efficient?

I want to know which of the 2 queries below is faster :- Select s.*, sm.* from tblStudent s Inner Join (SELECT studentId,SUM(marks) As Sum from tblStudentsMarks Group By studentId) as sm on s.StudentID = sm.StudentID; ...or: Select s.studentId, s.Name, SUM(Marks) From tblStudent s...

stored proc from excel with parameters

If I create a stored proc in sql that has a parameter, can I run that from Excel? ...

The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.

Assign datetime value in code in silverlight and save it to db by domainservice and EF: DateCreated = DateTime.Now in database, the mapped column datetype is datetime, not datetime2. then got following error: The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. How to fix it? ...

Help with string formatting in SQL Server Query

Hello, I have the following SQL query: SELECT DISTINCT ProductNumber, PageNumber FROM table I am trying to modify the query so that PageNumber will be formatted. You see, PageNumber is in any of the following formats, where 'x' is a digit: xxx, xxx xxx xxx-xxx xx, xxx-xxx xx-xx, xxx xx-xx, xxx-xxx I want to format PageNumber so th...

How can I get the username from a MS Access front end MDW in a SQL back end audit table?

I have an MS Access 2003 mdb and mdw which is connected to a SQL server backend. The tables are linked using a system DSN. I have a trigger on a SQL back end table which inserts a record into another back end audit table on insert, update, and delete. This all works well, but the trigger is using system_user to get the person making the ...

LINQ and TranscationScope not working

I am using LINQ select statement wrapped in a TransactionScope (to change the locking) but according to SQL Profiler, it doesn't seem to be working. My code looks like: using (var ts = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted} )) { using (myDBDataCo...

Is it possible to access the FILESTREAM share?

What I mean is being able to access it through Windows Explorer or other programs. I believe the answer is that it isn't possible. But I really want to know why it's not allowed. It seems that the files could be made available read-only through the network share. ...

Can anyone fathom a why do this or how it works correctly with this bit of SQL?

I've changed the table names but I found this FROM statement in a SP I'm optimizing and I'm wondering the how this could come into being, why would you ever do anything like this, and why does it still work. FROM tblPezFill pf RIGHT OUTER JOIN tblWolveLocation stfl RIGHT OUTER JOIN tblDuckPez pp RIGHT OUTER JOIN tblChaos o I...

Timezone Daylight Saving problem in PHP and SQL

So in my PHP code, I do timezone selection for the user, where I have a table of timezones and their hour-shift values from GMT. I then use that to add to the DATETIME column values whenever the user picks his timezone in the SETTINGS. So I have two functionalities: reading from DATETIME column in the database, and WRITING to the DATETI...