sql-server

Hashbytes comparison in stored proceduring not matching record

The password field in my user table (SQL Server 2008) is encrypted using HASHBYTES on insertion. I have a stored procedure with parameters for the username and plain-text password which does a SELECT using that username and the password sent through HASHBYTES, then returns the user record if it finds a match. The SP is always returning...

Repeating Chart in SSRS?

Hi, I'm working on some reports in SSRS 2005. I have a bit of experience of SSRS, but I can't figure out for the life of me how to do this. The report pulls in a data set from a stored procedure. Then I basically want to generate a Pie Chart for each row in the dataset. How on earth can I make the chart control repeat n times? is i...

What approach/design path should to take when building a totally new system?

This application I'm tasked with is basically a CRUD system for what will likely amount to about a dozen tables. The technology is likely ASP.NET WebForms + Ajax Ctrl Toolkit + jQuery on the front side, and SQL Server on the backside. This app will likely never be used by more than 10-20 users at a time as its a single-tenant system; ...

SQL Server Backup Files

Is the structure of SQL Server database backup BAK file similar to NTBackup BKF file? Is there any reference which can be redirected to understand the difference between NTNAckup and SQL Server Backup (*.bak) files? ...

What is the best way to keep password in SQL Server 2008?

Hi there, I am planning to save customer's sensitive information through SQL Server certificate/ (a)symmetric keys. Though data is secure now, certificate and keys are not readable, i wonder where should i put the keys? Is there any best practices? only thing i could think of is to create table only accessible to dbo or dedicated login ...

How do I order by on a varchar field that could contain numbers alphabetically?

I am sure that this must be quite a common problem so I would guess that Microsoft have already solved the problem. My Googling skills are just not up to scratch. I have a field that I want to order by, it is a varchar field, for example Q Num 10 Num 1 A Num 9 Num 2 F Now I would expect the result to be A F Num 1 Num 2 Num 9 Num ...

SQL Server: reasonable "auto increment" techniques?

I'm using SQL Server 2005 for the first time, having mostly worked with MySQL in the past. I'm used to using auto_increment to create unique IDs in tables. Anyway... I'm working in a java app, and need to do the following. Presume my table has two columns: itemID (int) and itemValue(int). This is basically what I want to do (the dbco...

How to speed up a SQL Server query involving count(distinct())

I have a deceptively simple SQL Server query that's taking a lot longer than I would expect. SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED SELECT COUNT(DISTINCT(guid)) FROM listens WHERE url='http://www.sample.com/' 'guid' is varchar(64) NULL 'url' is varchar(900) NULL There is an index on guid and url. There are over 7 million ...

What's the equivalent of mysql's 'SHOW PROCESSLIST' on SQL server?

We're in the process of converting to SQL Server from MySQL. I'm trying to figure out why a call to sqsh isn't returning and I suspect that there's some lock I don't know about. How do you find out what's going on (preferably via the database connection)? ...

How can I get a stored procedure to call an outside database on the same SQL server?

I am dealing with a web application that uses 2 different databases to store information. These databases have some database keys that refer to records in the other database. I would like to be able to write a stored procedure in SQL 2005 that can modify data in the current database as well as go out and modify some data in the other...

SqlClient Xml Output parameter "was not supplied"

I receive an SqlException when running the following code. "Procedure or function 'usp_Search' expects parameter '@pxmlSearchOutput', which was not supplied." My parameters + request. using (var connection = new SqlConnection(_connectionString)) { using (var command = new SqlCommand("Search.usp_Search", con)) {...

Can parameterized queries be fully captured using DBCC INPUTBUFFER?

In SQL Server 2008, I am using triggers to capture all changes made to a specific table in my database. My goal is to capture the entire change. That is, to capture what data is being inserted, not just that data is being inserted. In the trigger I am using the EventInfo column of the result set returned by DBCC INPUTBUFFER to get the...

SQL - help on "top 1 by group"

Relevant tables: DepartmentPhone: DepartmentPhoneID int, DepartmentID int, PhoneID int Phone: PhoneID int, PhoneType int There are 6 phones with PhoneType=4 that belong to DepartmentID=2. So this produces 6 records: select * from DepartmentPhone join Phone on Phone.PhoneID = DepartmentPhone.PhoneID and Phone.PhoneType = 4 where Depar...

Characters to use for \r\n when inserting into SQL Server

I'm attempting to insert some data from MySQL to SQL Server. I've dumped the MySQL table to a text file as SQL insert statements. I can insert it into SQL Server ok but the carriage returns are inserting as \r\n rather than as control sequences. How can I replace the \r\n strings in the MySQL insert statements so that they will end up as...

Does the Microsoft SQL Server native client support IDBAsynchNotify?

I'm working on some OLE DB code that runs queries on MS SQL Server via ICommand::Execute. I'm converting this code to operate asynchronously by setting the DBPROPVAL_ASYNCH_INITIALIZE property on the command before executing. I'd prefer to register a IDBAsynchNotify sink so that my code can be notified of events, as opposed to polling o...

Querystring encryption in sql server

I need to create a token to appear on a querystring that can be passed to a web page and decoded in order to find a record in a database view. The token should not be vulnerable to brute force incrementing value type attacks. View records in the database are uniquely defined as a combination of two keys. The generation of this token n...

Oracle SQL Developer 2.1 - Filter not working when using JTDS extension (v1.5 still working)

Dear all, I've upgraded to Oracle SQL Developer 2.1 and installed JTDS extension to work with SQL Server. But when I open the Data tab of a table, I cannot use filter features. I've check with an Oracle db, it works fine! Is there anyone get this trouble? Any suggestions are welcome! Thanks, ...

Including initial value in a select Statement

Hi, I have a select query which returns the following o/p.. 1 Arun, 2 Kumar, 3 Babu, 4 Ram, Is it possible to add a intial value to this o/p without inserting a value to the table, in other means hardcoding the intial value. Can i get the o/p as 0 Select, 1 Arun, 2 Kumar, 3 Babu, 4 Ram ...

Slow Update vs Slow Select

This is a question about tradeoffs. Imagine a social network. Each user has a status message, that he can change anytime. Whenever he does change it, all his friends are notified through a wall (like in Facebook). To make this work. We have 3 tables Users(id, name), FriendLists(userId, friendUserId), Notifications(?). Now let's assume...

Why does OPENXML seem to perform better than XQuery in this case?

I wrote the script below in order to test the performance difference between OPENXML and the newer functions available for the XML datatype in SQL Server 2005. When I run the script (with the option to include the actual execution plan), the results were strange. The execution plan said that the cost of the first query (using OPENXML) ...