sql-server

Which Namespaces Must Be Used to Connect to SQL Server with ADO.NET?

i am using this example to connect c# to sql server. can you please tell me what i have to include in order to be able to use sqlconnection? it must be something like: using Sqlconnection; ??? string connectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=""C:\SQL Server 2000 Sample Databases\NORTHWND.MDF"";Integrated Security=...

Creating SQL Server index on a nvarchar column

When I run this SQL statement: CREATE UNIQUE INDEX WordsIndex ON Words (Word ASC); I get the following exception message: The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'dbo.Words' and the index name 'WordsIndex'. The duplicate key value is (ass). The statement has been term...

Updating Database from DataSet

I am having trouble updating my Database from my code using a DataSet. I'm using SQL Server 2008 and Visual Studio 2008. Here is what I've done so far. I have created a table in SQL Server called MyTable which has two columns: id nchar(10), and name nchar(50). I have then created a datasource in my VB.net project that consists of this ...

Table valued function only returns CLR error

I have read-only access to a database that was set up for a third-party, closed-source app. Once group of (hopefully) useful table functions only returns the error: Failed to initialize the Common Language Runtime (CLR) v2.0.50727 with HRESULT 0x80131522. You need to restart SQL server to use CLR integration features. (severi...

Capture query results using SQL Server Profiler

It's possible to capture a query's result using SQL Server Profiler? i.e. the resultset generated by the query ...

java.sql.SQLWarning: [Microsoft][SQLServer 2000 Driver for JDBC]Database changed to X

Hi all, I'm using Hibernate 3.2.1 and database SQLServer2000 while I'm try to insert some data using my dao, some warning occurred like this: java.sql.SQLWarning: [Microsoft][SQLServer 2000 Driver for JDBC]Database changed to BTN_SPP_DB at com.microsoft.jdbc.base.BaseWarnings.createSQLWarning(Unknown Source) at com.microsoft....

problem with codeigniter using odbc database driver

i’ve run into a curious problem with codeigniter's odbc driver. i’m connecting from a linux machine to an MSSQL 2008 machine using FreeTDS. while i get that the ‘num_rows’ function always returns -1, and that is fully a database/driver issue - for some reason when i try to create a ->result(), the whole application crashes (error 500, s...

When saving to a model, created and modified aren't automatically populated by CakePHP. Using SQL Server

Hi when saving to a model, my created and modified fields aren't automatically populated by CakePHP. It was automatically populated when I was using MySQL but now it isn't. I'm not using NOW() back when I was still using MySQL. Why is it? Also when a field's value is not set 'NULL' (with quotes) is inserted causing errors because SQL Ser...

SQL IDENTITY COLUMN

Hey guys i am have an sql table which is basically a statement. Now lest say the records i have in my table have a date and an identity column which is autonumbered and defines the order which the transactions are displayed in the front end to the client. The issue is during an insert some of the data have gone missing and some transact...

how to detect sql server timeout from .NET application without using catch Exception

Hi, In my current application, i am performing an update by invoking T-SQL Update command. The problem is when the same record is locked by other users at that time. At .NET application, the application will wait until SQL Server timeout, then it will throw the SqlException timeout. Is it possible to perform a check first whether a p...

Out Parameters in Stored Procedures

Hi, Let's think that a stored procedure takes an out parameter. When this stored procedure is called with this out parameter is already initialized to something, does this situation cause an exception? thanks. ...

Changes to a table-valued function called by a stored procedure are not recognized?

Hey all I have a stored procedure sp that calls a table-valued function tvf. Sometimes I modify the tvf but when subsequently executing sp, the output from sp is the same as before the modification. It seems like it is cached or compiled or something. If I make some dummy change to the sp, then I get the right output of the sp. Is ther...

SQL Server: Views that use SELECT * need to be recreated if the underlying table changes

Is there a way to make views that use SELECT * stay in sync with the underlying table. What I have discovered is that if changes are made to the underlying table, from which all columns are to be selected, the view needs to be 'recreated'. This can be achieved simly by running an ALTER VIEW statement. However this can lead to some pret...

What are the APIs used by SQL Profiler?

SQL Server Profiler displays a live stream of commands being executed against a SQL server instance. What are the APIs used to capture this data? Background: I need to write a small utility (in C++) which tracks the SQL commands being issued by a separate application. ...

How to upload files and store them in a server local path when MS SQL SERVER allows remote connections?

I am developing a win32 windows application with Delphi and MS SQL Server. it works fine in LAN but I am trying to add the support for SQL Server remote connections (= working with a DB that can be accessed with an external IP, as described in this article: http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277). Basically I hav...

CakePHP and SQL Server 2008, Group By not working

Whenever I do a: $this->Job->find('all', array( 'group' => array('Job.some_field'), 'recursive' => -1 )); I get a : SQL Error: Column 'jobs.id' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. With MySQL it works fine but with SQL Server 2008 it se...

Sql Server trimming float data type

Hi, I have a float datatype and it gets assigned to 10 decimal points. when i try to convert this datatype to varchar, it retains 5 decimal points and trims the rest of the decimal values. @final varchar(8000) select @final=convert(varchar(8000),@final) it would be really appreciated if you could help me on this! Thanks ...

SQL Server 2005 script with join across Database Servers

I have the following script which I use to give me a simple "diff" between tables on two different databases. (Note: In reality my comparison is on a lot more than just an ID) SELECT MyTableA.MyId, MyTableB.MyId FROM MyDataBaseA..MyTable MyTableA FULL OUTER JOIN MyDataBaseB..MyTable MyTableB ON MyTableA.MyId = MyTabl...

Getting Null value Of variable in sql server

Strange situation In a trigger i assign a column value to variable but gives exception while inserting into other table using that variable. e.g select @srNO=A.SrNo from A where id=123; insert into B (SRNO) values (@srNo) // here it gives null I run above select query in query pane it works fine but in trigger it gives me null any su...

How Can I do this??

I have a table records(ID, ParentID) containg this data ID ParentID 1 null 2 1 3 2 4 2 5 3 6 null 7 6 If you draw this table in hierarchy as a family 1,2,3,4,5 will be related to each other. I want to find a way, where I can pass an ID like 3 it give me the others family members using SQL or us...