sql-server

how to manage more than one site admin and users in database?

I have to design a database for a application which is having millions of users.Now that website will be having multiple administrator like HRadmin,SuperAdmin,SalesAdmin.I can only have one role as Admin. My concern is that if i handle all user related data in one table,means all users,whether admin or user,credentials will be stored in...

Best way to store and select multiple states/cities for a Company?

Hello, I have Company A. I need the ability to link this Company to multiple States, and each state can in turn be linked to multiple Cities. For example: Company A \ - State A |-City A |-City B \ |-City C - State B |-City A ...

Unit Testing for VBScript, ASP Code and SQL Server 2000

I have a very old project implemented in (classic) ASP and SQL Server 2000. Because of quality concerns, I've been considering the possibility of implementing some form of automated quality testing. Though, the web pages are ASP the project is really 85% SQL Server stored procedure, functions, views and DTS. (Lots of dependency on DTS) ...

SQL Server features/commands that most developers are unaware of.

Possible Duplicate: Hidden Features of SQL Server I believe that this question has incorrectly been closed as an exact duplicate. 19 people have this question favorited so I do not believe this is an incorrect assumption. In the question, I am not asking about hidden features as in the other question, I'm ask about features/comm...

T-SQL datetimes substracting.

I've got a column Start and column End. I want to get number of hours and minutes between them. Select cast(End - Start as varchar) gives strange results, for example 2009-07-24 06:16 - 2009-07-24 06:30 gives result 12:14AM... It is important to cast it as varchar because later I will be cutting substrings out of this string with right()...

In SQL 2005 how do I move the distmdl.mdf and distmdl.ldf files?

I'm migrating my SQL server system databases to a new drive and can't find any documentation how to move this database. Thanks!! ...

SQL Server - Selecting Most Recent Record to generate a list of changes

Here is the situation: I have a database of 'tickets', and we track changes to the tickets each time they are saved. I am specifically looking at status changes, which track with the following format: STATUS:{FROM}:{TO} with {FROM} and {TO} changing to the respective statuses. What I need to do is generate numbers by weeks of the amou...

SQL Server Reporting Services - Report Model: API (build custom report builder)

I am looking into the idea of creating a custom report builder and data tool to replace the ssrs report builder. I am wanting something more like a query builder and data export tool rather than reporting. The thing I want to use is the report model. I want users to select field from report model, render the sql, then exec sql and retu...

how can I test performance in Sql Server Mgmt Studio without outputting data?

Using SQL Server Management Studio. How can I test the performance of a large select (say 600k rows) without the results window impacting my test? All things being equal it doesn't really matter, since the two queries will both be outputting to the same place. But I'd like to speed up my testing cycles and I'm thinking that the output ...

How can I do server side pagination of results in SQL Server 2000?

In SQL Server 2005, there is a feature called row_number() which makes pagination very simple. SELECT * FROM table WHERE row_number() between x and y Is there any SQL server way to do the same thing in SQL Server 2000? (Note: I don't have access to a unique sequential numbering for the query, i.e. something which would be a synonym f...

What are the differences between CHECKSUM() and BINARY_CHECKSUM() and when/what are the appropriate usage scenarios?

Again MSDN does not really explain in plain English the exact difference, or the information for when to choose one over the other. CHECKSUM Returns the checksum value computed over a row of a table, or over a list of expressions. CHECKSUM is intended for use in building hash indexes. BINARY_CHECKSUM Returns the binary checksu...

Error Handling in User Defined Functions

I want to write a non-CLR user-defined function in SQL Server 2005. This function takes an input string and returns an output string. If the input string is invalid, then I want to indicate an error to the caller. My first thought was to use RAISERROR to raise an exception. However, SQL Server does not allow this inside a UDF (though yo...

Sql Server Composite Primary Key

I found something today in one of my databases that I cannot explain. I noticed on one of my tables that there was a foreign key made up of two fields which referenced the same two fields on the same table. These two fields were also the same two fields which made up the composite primary key. For example: Table: Listings Primary Key...

Best practices when inserting data into a view

I have a few views and I want to insert some data into them. I've heard you need to "be careful when doing this", and you need to "setup the view to make the insert work correctly". What do I need to look for, and what if anything do I need to do to my view to allow insertions into it? Is better to insert into the underlying tables ev...

SQL Server schema best practises

I'm in the process of designing a new database for an application. I'd like to be mindful of the security from the start (which should be the norm!). Anyone got a link to a resource describing the best way to use schemas to implement good security? By using schemas, I mean not just dumping everything under the default dbo schema. Surel...

Best way to store large dataset in SQL Server?

I have a dataset which contains a string key field and up to 50 keywords associated with that information. Once the data has been inserted into the database there will be very few writes (INSERTS) but mostly queries for one or more keywords. I have read "Tagsystems: performance tests" which is MySQL based and it seems 2NF appears to be ...

Analysis Services Dimension - best way to handle description or friendly name

If I have a dimension in Analysis Services where the base table has columns like this: TransTypeKey TransTypeCode TransTypeDescription TransCategoryCode TransCategory Description where the description columns are just friendly names for the corresponding 'code,' what's the best way to capture that? Concatenate the code and description...

Best way to lookup the default value of a column in Sql Server

I want to lookup the default value of a column in my SQL2005 database. I only have the SQL server connection string, so I can only use the Sql library namespace (can't use the Oledb GetSchema stuff). I know there is a GetSchema()... but how do I use it to get a column schema, and thus the default value? I can't fillSchema on a datatab...

Where can I find SQL statements to create EAV model?

Alternatively, anyone know of where I can get the EAV model for Erwin? ...

How to encrypt Sql connection string ?

I have a WCF Service which connect to Sql Server 2005 to retrieve and send data according to the method invoked. Currently I am using a hard coded sql connection string in .cs file to create a connection. Let me know what is the best way to use the connection string or where i place the connection string? Please help!! ...