sql-server

SQL Server 2005 IsNumeric Not catching '0310D45'

I've got this value '0310D45' I'm using isnumeric to check if values are numeric prior to casting to a bigint. Unfortunately this value is passing the isnumeric check. So my query is failing saying: Msg 8114, Level 16, State 5, Line 3 Error converting data type varchar to bigint. What is the simplest way to handle this. I was thinki...

SQL Server Multiple Joins Are Taxing The CPU

I have a stored procedure on SQL Server 2005. It is pulling from a Table function, and has two joins. When the query is run using a load test it kills the CPU 100% across all 16 cores! I have determined that removing one of the joins makes the query run fine, but both taxes the CPU. Select SKey From dbo.tfnGetLatest(@ID) a le...

SqlMetal, Sql Server 2008 database, Table with HierachyID, dal cs file is created sometimes ?

I have 2 databases with a 2 tables with HierachyID fields. For one database I can get a dal cs file, for the other database I cannot get a dal cs file ? HBus is a database I can get the dal cs for, ... SqlMetal /server:.\SQLSERVER2008 /database:HBus /code:HBusDC.cs /views /functions /sprocs /namespace:HBusDC /context:HBusDataContext ...

Recommendations for supporting both Oracle and SQL Server in the same ASP.NET app with NHibernate

Our client wants to support both SQL Server and Oracle in the next project. Our experience comes from .NET/SQL Server platform. We will hire an Oracle developer, but our concern is with the DataAccess code. Will NHibernate make the DB Engine transparent for us? I don't think so, but i would like to hear from developers who have faced si...

Which one can have better performance - LINQ to EF or NHibernate?

I want to start working on a big project. I research about performance issues about LINQ to EF and NHibernate. I want to use one of them as ORM in my project. now my question is that which one of these two ORM can get me better performance in my project? I will use SQL Server 2008 as database and C# as programming language. ...

How to build a database from an XSD schema and import XML data

I have a complex XSD schema and hundreds of XML files conforming to the schema. How do I automate the creation of related SQL Server tables to store the XML data? I've considered creating C# classes from the XSD schema using the xsd.exe tool and letting something like Subsonic figure out how to make a shiny database out of it, but not ...

Can you set SQL Server permissions from a Silverlight app?

Is it possible to create a Silverlight application which can be used to provide a nice user interface for managing SQL Server permissions? We want to create a simple admin app to allow certain users to create new users, disable old users, and manage specific permissions for those users, but we feel that SQL Server Management Studio is p...

Advice on optimzing speed for a Stored Procedure that uses Views

Based on a previous question and with a lot of help from Damir Sudarevic (thanks) I have the following sql code which works great but is very slow. Can anyone suggest how I can speed this up and optimise for speed. I am now using SQL Server Express 2008 (not 2005 as per my original question). What this code does is retrieves paramet...

Switching to sequential (comb) guids - what about existing data?

We have a database with 500+ tables, in which almost all the tables have a clustered PK that is of datatype guid (uniqueidentifier). We are in the process of testing a switch from "normal" "random" guids generated through .NETs Guid.NewGuid() method to sequential guids generated through the NHibernate guid.comb algorithm. This seems to...

Getting the 'date' out of a DateTime field in SQL Server

I have a date column where the date is displayed in the format 2009-11-18 10:55:28.370. I just want to get the date (not time) out of that value. How do I do that? ...

Is this method a good aproach to get SQL values from C#?

I have this little method that i use to get stuff from SQL. I either call it with varSearch = "" or varSearch = "something". I would like to know if having method written this way is best or would it be better to split it into two methods (by overloading), or maybe i could somehow parametrize whole WHERE clausule? private void sqlPo...

Why can't I enter an integer value into a decimal field?

I'm trying to write an insert statement for a SQL Server table that inserts the value 1 into a decimal field. The field is of the type decimal(10, 10) which, as far as I understand, means that it can have up to 10 digits altogether, and up to 10 of those digits can be after the decimal point. But, when I try to run the insert statement I...

Converting data in SQL Server

I am loading in a bunch of data that contains dates formatted as shown below: 00-JAN-0000 00-FEB-0000 00-MAR-0000 00-APR-0000 00-MAY-0000 00-JUN-0000 00-JUL-0000 00-AUG-0000 00-SEP-0000 00-OCT-0000 00-NOV-0000 oo-DEC-0000 SQL cannot automatically convert these dates because it does not recognize the month part of the date. I have appro...

Accessing SQL Server using an IP Address and Port Number ... Help!

I need to access an SQL Server that is on a machine behind a firewall and you access this machine using an ip address like 95.95.95.33:6930 (not the real ip address) ... But, you get my point that by accessing 95.95.95.33 on port 6930, the firewall routes the requests to that particular machine ... My question is ... How do you construc...

Autocommit and multiple SqlConnections

Is an insert with autocommit guaranteed to be immediately visible to any/every SqlConnection on the database, or only on it's own SqlConnection? I have a procedure with 3 SqlConnections. Connection One is associated with a SqlDataReader which is driving a loop. Withing the loop, Connection Two is used to get data for test, and Connectio...

Reading greek text from jdbc / SQL Server 2005 and displaying it with a servlet

Well, the subject says it all but I will explain a little further. I have a database in MS SQL server 2005 that contains greek text. I have created a servlet that connects to that database using net.sourceforge.jtds.jdbc.Driver and receive some data with the following commands: Connection con = DriverManager.getConnection(connectionUr...

Help Reading Binary Image Data from SQL Server into PHP

I cannot seem to figure out a way to read binary data from SQL server into PHP. I am working on a project where I need to be able to store the image directly in the SQL table, not on the file system. Currently, I have been using a query like this one: INSERT INTO myTable(Document) SELECT * FROM OPENROWSET(BULK N'C:\image.jpg',...

Need to remotely create an ODBC connection to a SQl server.

I have an Access 2007 database with a table in it that is linked to a SQL server. I need to roll this version of the database out to approximately 10 people in different states. In order to do that, they need an ODBC connection to the SQL server installed on their machines. I am looking for a way to do this remotely. Either through VBA i...

SQL 2008 Database tuning advisor won't start

For some reason I can't get DTA to connect to my development machine. It connects to a remote DB just fine but when I point it to my dev machine I get an error saying: Failed to initialize MSDB database for tuning (exit code: -1073741819). I'm pretty sure it's not a permissions issue since I've used profiler to capture what it's doing ...

Using a .MDF SQL Server Database with ASP.NET Versus Using SQL Server

I'm currently writing a website in ASP.NET MVC, and my database (which doesn't have any data in it yet, it only has the correct tables) uses SQL Server 2008, which I have installed on my development machine. I connect to the database out of my application by using the Server Explorer, followed by LINQ to SQL mapping. Once I finish deve...