sql-server

ADO.NET zombie transaction bug? How to ensure that commands will not be executed on implicit transaction?

e.g. When deadlock occurs, following SQL commands are successfully executed, even if they have assigned SQL transaction that is after rollback. It seems, it is caused by a new implicit transaction that is created on SQL Server. Someone could expect that ADO.NET would throw an exception that the commands are being executed on a zombie tr...

SQL Compact 2008 Connection String Problem

I have the following code to connect to a sql server compact edition 2008: private SqlConnection sqlConn; public void createConnection() { String connectionString = @"Data Source=C:\Projects\somefile.sdf;Persist Security Info=False"; sqlConn = new SqlConnection(connectionString); sqlConn.Open(); ...

How to choose light version of database system

I am starting one POS (Point of sale) project. Targeting system is going to be written in C# .NET 2 WinForms and as main database server We are going to use MS-SQL Server. As we have a lot of POS devices in chain for one store I will love to have backend local data base system on each POS device. Scenario are following: When main serve...

The future of SQLServer Service Broker

Hi all, is there any information on the future of the Service Broker infrastructure in SQLServer? The team's blog (http://blogs.msdn.com/b/sql_service_broker/) is not very active and there were only minor changes in SQL 2008 R2 release. When building now a distributed system that needs async queueing and there is already a SQLServer / ....

Can I select a set of rows from a table and directly insert that into a table or the same table in SQL?

Hi all I was just curious if I could do something like - insert into Employee ( Select * from Employee where EmployeeId=1) I just felt the need to do this a lot of times...so just was curious if there was any way to achieve it.. ...

how to enter manual time stamp in get date ()

how to enter manual time stamp in get date () ? select conver(varchar(10),getdate(),120) returns 2010-06-07 now i want to enter my own time stamp in this like 2010-06-07 10.00.00.000 i m using this in select * from sample table where time_stamp ='2010-06-07 10.00.00.000' since i m trying to automate this query i need the curre...

SQL query for getting data in two fields from one column.

I have a table [Tbl1] containing two fields. ID as int And TextValue as nvarchar(max) Suppose there are 7 records. I need a resultset that has two columns Text1 and Text2. The Text1 should have first 4 records and Text2 should have remaining 3 records. [Tbl1] ID | TextValue 1. | Apple 2. | Mango 3. | Or...

How to query database where date and time field are separate?

In Table, Time and date fields are two separate fields. I need to make a query something like this give all records where date and time <= givenDateTime. How do i do that please? EDIT My query:- select DateField, TimeField from Table1 where DateField <= '07/26/2009' and TimeField <= '16:26:20' Result is:- 2008-04-22 00:00:00.000 189...

Encryption from c# application

SITUATION: I need to make encryption happen between my remote database and my c# application. I don't know what I'm doing (never done any encryption before) and all the stuff I found on the web was for asp.net and dealt with the web.config file. SOME RELEVANT DATA: My connection string contains password info for SQL server authenticatio...

Selecting data in clustered index order without ORDER BY

I know there is no guarantee without an ORDER BY clause, but are there any techniques to tune SQL Server tables so they're more likely to return rows in clustered index order, without having to specify ORDER BY every single time I want to run a super-quick ad hoc query? For example, would rebuilding my clustered index or updating statis...

How to convert row data into columns in SQL

Hi, I have looked into pivot but I think it requires an aggregate function which I do not need (I think). The result of my query is this Name Property Name PropertyValue ---------- ---------- ---------- lorem Work Phone 000.111.2020 ipsum Email tes...

How to realize this in Transact SQL ( SQL Server 2008 )

I just want an update trigger like this postgresql version... It seems to me there is no NEW. and OLD. in MSSQL? CREATE OR REPLACE FUNCTION "public"."ts_create" () RETURNS trigger AS DECLARE BEGIN NEW.ctime := now(); RETURN NEW; END; Googled already, but nothing to be found unfortunately... Ideas? Update: Sth, like this? CREATE ...

SQL Server Express: Failed to add primary key after creating a database table

Scenario: I have created a database table. And when I tried to add a primary key (using the SQL Server Management Studiio) to the table, it failed with an error message "Saving changes is not permitted. The changes you have made requrie the following tables to be dropped and re-created. You have either made changes to a table that can't ...

T-SQL: How Do I Create A "Private" Function Inside A Stored Procedure

Okay so im writing a SQL Server 2008 Stored Procedure (maintenance script). In doing so, being a good boy i've done plenty of error handling, checking rowcounts, printing output messages, etc But in doing this, ive found myself writing over and over again something like this: SELECT @RowsAffected = @@ROWCOUNT IF @RowsAffected > 0 BEGI...

SQL Server connection help...

Using SQL Server 2005 I have the server connection name as (server1) in windows authentication mode, I want to change windows authentication mode to sql server authentication mode... when i try to change sql server authentication mode with username = sa & password = sa, it showing error... How to change the authentication mode or how ...

blank to numeric conversion derived column

Hi All, I have a source column with blank (not "NULL"), and target as numeric. while converting using the data conversion it is not converting due to balnk source value so I used derived column to replace a blank value with NULL or 0 as (source column == " ") ? "0" : source column but its not giving the value as 0 in the blank place. ...

In TSQL, how can I get the rindex functionality(search a substring from right and get the position)?

Hi guys, In TSQL, how can I get the rindex functionality(search a substring from right and get the position)? Great thanks. ...

Database schema publishing with SQL Server 2005/2008

Hi everybody, I've a question for you. We have built a software that has a single database for each customer. These databases are managed by SQL Server 2008. Now the problem is that when we build our software we, sometimes, need to change something on the schema (like adding table, modifying existing ones etc) and migrate these updates o...

How to synchronize two (or n) replication processes for SQL Server databases?

There are two master databases and two read-only copies updated by standard transactional replication. It is needed to map some entity from both read-only databases, lets say that A databases contains orders and B databases contains lines. The problem is that replication to one database can lag behind replication of second database, a...

SQL Server IS_NULLABLE

Good Morning, Just a quick question what this field actually means? I am trying to create an export script which follows this standard: lname varchar(30) **NOT NULL**, So if last name is_nullable=yes then would I put NULL rather than NOT NULL at the *'d code. Many Thanks, Joel ...