sql-server

Sql Server 2005: what data type to use to store passwords hashed by SHA-256 algorithm?

In Sql Server 2005 what data type should be used to store passwords hashed by SHA-256 algorithm? The data is hashed by the application and passed to the database ...

Streaming directly to a database

I'm using c#, and have an open tcpip connection receiving data. Is it possible to save the stream to an ms sql server database as I'm receiving it, instead of receiving all the data then saving it all? If the stream could be sent to the database as it's being received, you wouldn't have to keep the entire chunk of data in memory. Is t...

When is SqlConnection.RetrieveStatistics() useful?

What are the problems that calling this method can help with? Do you ever use it in debugging you data access? ...

Moving data from Sql Server to Excel via a Web Service

My users want data from my application in Excel. The data resides in a SQL Server database but I don't want the users to have direct access to the database, I would rather provide them a web service to get the data. What is the best way to move data from SQL Server to Excel via a web service? ...

Access Web Service from a SQL Server 2005 Stored Procedure

Hi everyone, Currently I have a stored procedure that makes some updates to a table, and after it makes them, I need to call a web service. The procedure uses a transaction, and I need to call the web service at the end of the transaction. If the web service call should fail, the transaction would get rolled back. I need to know how d...

No indexes on small tables?

"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." (Donald Knuth). My SQL tables are unlikely to contain more than a few thousand rows each (and those are the big ones!). SQL Server Database Engine Tuning Advisor dismisses the amount of data as irrelevant. So I shouldn'...

Dynamic patching of databases

Please forgive my long question. I have an idea for a design that I could use some comments on. Is it a good idea to do this? And what are the pit falls I should be aware of? Are there other similar implementations that are better? My situation is as follows: I am working on a rewrite of a windows forms application that connects to a SQ...

How to get database and tablenames along

How to get all the database names and corresponding table names together ? ...

Best primary key data type for Linq to SQL

I am starting new project with SqlServer and Linq to Sql. What data type would be better for surrogate keys in tables: identity or uniqueidentifier ? As I understood, identity is automatically generated on insert, while uniqueidentifier should be generated in code (GUID). Are there any significant performance differences? e.g. ident...

What are the fields that the user table should contain from the security/authenication perspective?

When designing user table what would be the must have fields from the security/user authentication point of view for a Web based Application (.NET and SqlServer 2005) I came with with the following fields: userID username -- preferably email passwordHash onceUsePassword -- to indicate that the password should be changed after login al...

How to split date column & sum it up

I have a query where i have a date column (time) which tells about "IN" & "OUT" timing of the people attendance by this single column My queries are :- 1) How to get the daily attendance of each employee 2) How to come to know if the employee is present less than 5 hours Please let me know the queries in SQL server. ...

How can I get SQL Server column definition with parentheses and everything?

I need a smart way to get the data types out of INFORMATION_SCHEMA.COLUMNS in a way that could be used in a CREATE TABLE statement. The problem is the 'extra' fields that need to be understood, such as NUMERIC_PRECISION and NUMERIC_SCALE. Obviously, I can ignore the columns for INTEGER (precision of 10 and scale of 0), but there are ot...

best way to consume a webservice in an asp.net code behind

Hello, I'm trying to bind a datasource to a repeater, for instance, to a web service (.asmx from a different website) on page load. The webservice returns a DataSet from an sql call. What is the best way to go about doing this? ...

Do numerical primary keys of deleted records in a database get reused for future new records?

For example if I have an auto-numbered field, I add new records without specifying this field and let DB engine to pick it for me. So, will it pick the number of the deleted record? If yes, when? // SQL Server, MySQL. // Follow-up question: What happens when DB engine runs out of numbers to use for primary keys? ...

Obfuscate a SQL Server Db schema

When posting example code or filing bug reports based on a real production app, it would be helpful to have some way to change the table and column names to not potentially give away information about the internals of the app. Doing it by hand without breaking things is time consuming. Does anything automatic exist? Ideally it would u...

In SQL 2005/2008 management studio, how to I get the 'summary' tab to be visible?

Hi, In SQL 2005/2008 management studio, how to I get the 'summary' tab to be visible? I close it by mistake and want to open it again...any way without restarting it? ...

Help With Basic SQL Query

I have a table with columns ID, DateStamp and the ID need not be unique. How do I write a query that will give me a list of IDs with the minimum DateStamp and the maximum DateStamp? So, for example, for a given ID, the output may look like: 938423, 1/1/2000, 12/13/2003 [I am running SQL Server 2000.] ...

Cannot truncate table because it is being referenced by a FOREIGN KEY constraint?

Using MSSQL2005, Can I truncate a table with a foreign key constraint if I first truncate the child table(the table with the primary key of the FK relationship)? I know I can use a DELETE without a where clause and then RESEED the identity OR Remove the FK, truncate and recreate but I thought as long as you truncate the child table you...

Can I use recursion in a Sql Server 2005 View?

I tried to use OPTION (MAXRECURSION 0) in a view to generate a list of dates. This seems to be unsupported. Is there a workaround for this issue? EDIT to Explain what I actually want to do: I have 2 tables. table1: int weekday, bool available table2: datetime date, bool available I want the result: view1: date (here all days in this...

Help with sql join

I have two tables: Table 1: ID, PersonCode, Name, Table 2: ID, Table1ID, Location, ServiceDate I've got a query joining table 1 to table 2 on table1.ID = table2.Table1ID where PersonCode = 'XYZ' What I want to do is return Table1.PersonCode,Table1.Name, Table2.Location, Table2.ServiceDate, I don't want all rows, In table 2 I'm only ...