sql-server

Subqueries are not allowed in this context. Only scalar expressions are allowed.

When I'm running this query on my page, I'm getting a Subqueries are not allowed in this context. Only scalar expressions are allowed error. What am I doing wrong? insert into Konular(KonuAd, AltKategoriID, KategoriID, KonuSahibi,GönderenID, İçerik,KonuTarih,SonMesajTarihi) values(@Başlık,'184','0',@KonuSahibi,'27',@İçerik,'0...

Using SQL Server as a DB queue with multiple clients

Given a table that is acting as a queue, how can I best configure the table/queries so that multiple clients process from the queue concurrently? For example, the table below indicates a command that a worker must process. When the worker is done, it will set the processed value to true. | ID | COMMAND | PROCESSED | | 1 | ... | tr...

how to get column name in SQL Server

How to get column name in SQL Server, and also how to execute that query in php , ...

Failed to open Crystal Reports

When I try to run crystal reports the following Error is appears: Transaction (Process ID 159) was deadlocked on lock | communication buffer resources with another process and has been chosen as the deadlock victim. Rerun the transaction Note: Report is connect directly to stored procedure. ...

What are the pros and cons of the following database design?

I am looking to for suggestions and commments about the following design. All the tables are expected to be large tables (millions of records) and are updated and queried often and any kind of update is allowed (update, insert, delete). -- product create table Product( productID int not null identity(1,1), name varchar(100) not null, ...

Equivalent of mssql_result in sqlsrv (Microsoft SQL Driver for PHP)

What is the equivalent function for mssql_result, under Microsoft SQL Driver for PHP (sqlsrv)? Please give example of using that function as well. I couldn't find any details on this online, unfortunately. ...

SQL Server 2008: Bulk Datatype Change

I have an SQL Server 2008 database with many tables. I've been using the now lame datetime datatype and want to use the new and better datetime2. In most places where I have a datetime field, the corresponding column name is Timestamp. Is there anywhere to do a bulk change from datatime to datetime2? ...

TDS incoming tabular data stream is incorrect. Data Type 0xFF is unknown

Hello all, I'm using FreeTDS driver for connecting to MSSQL server. I'm getting this error when trying to insert a new row into one of the tables. Can't insert new ABC::XYZ : DBD::FreeTDS::st execute failed: Server message number=8009 severity=16 state=1 line=1 server=SERVERNAME text=The incoming tabular data stream (TDS) remote proced...

How can you use variables or references in SQL?

In the following: (running a query on the Stack Exchange Data Explorer, which uses an SQL Azure implementation of OData. The FAQ says it supports most of the TSQL commands): DECLARE @MinPosts int = ##MinNumberOfPosts## SELECT Id AS [User Link], Reputation, (SELECT COUNT(*) FROM posts WHERE posts.OwnerUserId = Users.I...

Sql server 2008 codeSnippets or templates advice needed

Hi There are many tools out there some free and some not that offer a codesnippet facility. For some reasons in the company I work for they dont want to install or buy any third party stuff. I need to work with just sql server 2008. Is there a way to modify the templates so that when you choose create new SP it loads the custom sp. In a...

Is it possible to automatically prefix all table names in SQL Server and in LINQ to SQL?

I'm working on a few ASP.NET MVC projects which all require database functionality. Unfortunately, my hosting provider only gives me two SQL Server databases to work with, so I want to put the tables of multiple projects into a single database. However, some of my tables are similarly named, so I might run into some issues. Thus, I'm tr...

How to fetch the nth highest salary from a table without using TOP and sub-query ?

Hi, Recently in an interview I was asked to write a query where I had to fetch nth highest salary from a table without using TOP and any sub-query ? I got totally confused as the only way I knew to implement it uses both TOP and sub-query. Kindly provide its solution. Thanks in advance. ...

Create db from sql script in VS 2008

Hi, I have worked on Visual studio 2008 before, but do not have a lot of experience in working with databases. I have a Sql Script file which contains the complete information about the datanase that i am supposed to replicate and use in my project(which is a web site). Could someone guide me as to how am i supposed to use the Sql script...

asp.net quiz application

i want to create asp.net webforms, contain single multiple choice question on a form using formview que. and ans. from sql server table(sqldatasource). please give me a basic idea thanks ...

Code First Entity Framework 4 : Failing with SQL Authentication

I'm working with Entity Framework 4 and CTP 4 and am really liking it so far. I can get it working correctly when I'm using Windows Authentication to connect to the database but when I switch to SQL Authentication it fails with the message below. I've given the user a sysadmin role and it's default database is master. Error: This...

Selecting the top 5 unique rows, sorted randomly in SQL Server 2005?

I have a table in SQL Server 2005 that looks like 1 | bob | joined 2 | bob | left 3 | john | joined 4 | steve | joined 5 | andy | joined 6 | kyle | joined What I want is to give someone the ability to pull up the activity of 5 random users (showing their latest activity) ex: I want to return results 1, 3, 4, 5, 6 - or - 2, 3, 4, 5, ...

how to return number of records efficiently in SQL?

Hello everyone, I am using SQL Server 2008 Enterprise on Windows Server 2008 Enterprise. I am using the following code to return a part of data for a query to implement paging (i.e. page up/down to show a part of result at each page, like Google search result paging) on my web application (I use pageCount as number of results showed on ...

Combining Union results

I have the below SQL Query select Count(emailID) as ViewsThatMonth, Day(entry_date) as day, Month(entry_date) as month, Year(entry_date) as year from email_views where emailID = 110197 Group By Day(entry_date), Month(entry_date), Year(entry_date) UNION ALL select Count(emailID) as ViewsThatMon...

Is there any possible way to access a database server directly in Android?

Is there any way to access the a database server directly in Android? If not, why? Also, are there any external tools for this? ...

What indices should be created to optimize sql query with multiple OR conditions

I have a query like this: SELECT * FROM T WHERE A = @A AND (B=@B OR C=@C OR D=@D OR @E=E) ORDER BY F What indices should I add to improve query performance? Also I'll need to implement paging so this query will be more complex. My guess is that four indices should be created: (A, B, F), (A, C, F), (A, D, F) (A, E, F), but I'm not su...