sql-server

What's the best new development tool of 2009?

I am looking to do a presentation at work to our development team. I was wondering if their is any new tool which would be easy to demonstrate. It is just an after work thing for talking about new technologies. Thanks ...

Should I give a client a SQL Server login with the 'db_owner' role?

One of our clients has requested that we include the 'db_owner' role on the database login that their website uses, so that they can upload a script (an ASP page) to run some database changes. Normally the logins for the databases hosted on our server only include 'db_reader' and 'db_writer'. Is this ok, or should I request that they for...

Let a user view all info of sys.databaseprincipals

Hi, I have a database and I want let to some role the permission to query all info from the sys.databaseprincipals and see other user names. How can I do this? Thanks. ...

Making an MSSQL Driven Calendar in .NET c#

I'm new to .NET and my first project is to create a event calendar to be populated from a events table in mSQL. I know there is a calendar object in the standard components but wondered if i'm better off populating a table view manually as i didn't know if there were lots of limitations to the standard object/component. Thanks for your ...

How can I tell that SQL Server is started and ready to use?

I have an app that runs on system startup that needs to talk to the local SQL Server 2005 installation. I'm using the ServiceController class to wait for it to enter the "Running" state, and most times this works fine. However, sometimes on a cold boot, my first query fails, saying that it couldn't log on the current user. It sounds l...

How to create a database and populate it during setup

I would like to find a way to create and populate a database during asp.net setup. So, what I'm willing to do is: Create the database during the setup Populate the database with some initial data (country codes or something like that) Create the appropriate connection string in the configuration file I'm using .NET 3.5 and Visual St...

Preferred Method of Storing Passwords In Database

What is your preferred method/datatype for storing passwords in a database (preferably SQL Server 2005). The way I have been doing it in several of our applications is to first use the .NET encryption libraries and then store them in the database as binary(16). Is this the preferred method or should I be using a different datatype or all...

What's your favored method for debugging MS SQL stored procedures?

Most of my SPs can simply be executed (and tested) with data entered manually. This works well and using simple PRINT statements allows me to "debug". There are however cases where more than one stored procedure is involved and finding valid data to input is tedious. It's easier to just trigger things from within my web app. I have a...

Calculate the Last Day in the CURRENT quarter

What's the most efficient way to calculate the last day of the CURRENT quarter? Example: given the date 3/5/09, I want to return 3/31/09. Platform is ColdFusion and SQL Server ...

What is the best way to transfer a table or tables from one SQL server to another?

I have been developing in VB.NET and SQL Server 2008 for a while now, but haven't got into live installs yet. In the database system I used be on it had the ability to archive multiple tables into a .dga file, as it was called. I could then restore the .dga file into another database or on another server. I'm looking for the easiest way...

How to connect to SQL Server through proxy server

Is it possible to connect to SQL Server server through proxy (http) using SQLSERVER oledb provider? How can I specify proxy address and port in connection string if it's possible? What nonstandard methods to bypass proxy you'd recommend if it's not possible? ...

What is the equivalent of 'CREATE TABLE ... LIKE ..." in MSSQL

I am working with MSSQL (I am a MSSQL noob) and trying to alter a table. I want to CREATE TABLE LIKE to safely store data while I drop keys and constraints and all the other rigamorole that MSSQL seems to require when altering on the original table but I have not been able to find a match to that command... ...

SQL Insert Performance Improvement

I am writing an application that logs status updates (GPS locations) from devices to a database. The updates occur at a set interval for each device, which is currently every 3 seconds. I'm using a simple table in SQL Server 08 for storing each update. I've noticed that running the inserts is an area of slow down in my application. I...

Check for constraint on table

If I check for a column's existance as follows, before adding it, how would I do the equivalent for a UNIQUE constraint? IF NOT EXISTS (SELECT * FROM sys.columns WHERE object_id=OBJECT_ID('[Table]') AND [Name]='Column') ALTER TABLE [Table] ADD [Column] varchar(500) ...

TSQL - When to use 'not null'

What general guidelines should I go by when considering whether I should mark a field 'not null' as opposed to just declaring everything but the primary key null? Should 'not null' fields have DEFAULT values? ...

What profiler to use with sql express?

is there a way to monitor detail of sql calls in express version? ...

Migrate and Merge several databases into one

In an update project i have to do the following: Move 3 databases from SQL2000 to SQL2005 and merge them at the same time. There are already quite a few cross database queries used in SP's and Views. The current plan is to move each of the old databases into a separate schema in 1 database. That means we will also have to change our cu...

Options on installations of sql server 2008 express?

I'm installing sqlserver 2008 express and I have a couple of questions, by default on the collation, it has SQL_Latin1_General_CP1_CI_AS I'm just wondering which collation I should choose so that it can store all languages, English, Asian etc. also this is a brand new installation on a brand new box, should I use Default Instance or ...

Query duration estimation in SQL Server

I've seen in Oracle 10g a feature that estimates the remaining time for a long running query and I was wondering if this is possible too in SQL Server (at least in 2008?)? Suppose I have a very large table with tens of millions of rows (well indexed etc. etc.) and I need to search for some particular rows. I know it will take a lot of t...

How to properly create an index

I have the following very large table in SQL Server 2005: create table Blah ( FirstName varchar(30), Rank int, Position int, ... ) I will run the following query on it: declare @PassedInFirstName varchar(30) set @PassedInFirstName = 'SomeName' select TOP 1 Position from Blah where FirstName = @PassedInFirstName order by Ran...