sql-server

Dynamically create temp table, insert into temp table, and then select

Basically i want to be able to dynamically create a temp table based off of an existing table, and then insert values into the temp table, and select the inserted values. i've got the part where i can create the temp table working just fine, it's just that inserting and selecting form it aren't working too well. here's my current code....

Having trouble adding a linked SQL server

I'm trying to pull in data from a remote SQL Server. I can access the remote server using SQL authentication; I haven't had any luck using the same credentials with sp_addlinkedserver. I'm trying something like this: Exec sp_dropserver 'Remote', 'droplogins' go EXEC sp_addlinkedserver @server='Remote', @srvproduct='', @pr...

How to grant permissions to SqlServer 2005 system stored procs (e.g. sp_start_job)

I want to be able to invoke an SSIS package at will from a web application. I've found that I can do this successfully with sp_start_job when running on my local machine. However, when I publish to our test site, I get: The EXECUTE permission was denied on the object 'sp_start_job', database 'msdb', schema dbo' So I tried this USE...

How do I increase the timeout period for my stored procedure call (see error)?

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: Syste...

Asp.net Webapplication on a multiple servers

I was wondering what do i need to get my asp.net web application installed on multiple server, having them working as a one piece. Thanks in advance, ...

Database-Generated Human-Friendly Codes

I'd like to create some human-friendly codes to identify my objects. I'm thinking about using the following rules: 6-digit random number the first character is not zero each code has an edit distance value of 2 or greater* from every other such code maybe a checksum too I'd like my MS SQL database to enforce that the codes I use are...

Create Foreign Key SQL

How do I create a foreign key from table tGeoAnswers column 'locationId' to table tLocations column 'id'? ALTER TABLE tGeoAnswers ADD FK_Answer_Location FOREIGN KEY (locationId) REFERENCES tLocations(id) I am trying this code that I found but I get the following error: The definition for colu...

SQL: Using Top 1 in UNION query with Order By

I have a table as below Rate Effective_Date ---- -------------- 5.6 02/02/2009 5.8 05/01/2009 5.4 06/01/2009 5.8 12/01/2009 6.0 03/15/2009 I am supposed to find the all rates that are effective for current date and after it. So to get the current effective rate, i use SELECT TOP 1 * from table where effective_date < '05/05/2009...

connect to ms sql server 2008 using management studio 2005

is there any way to connect to ms sql server 2008 using management studio 2005? ...

Using Sql Server with Django in production

Has anybody got recent experience with deploying a Django application with an SQL Server database back end? Our workplace is heavily invested in SQL Server and will not support Django if there isn't a sufficiently developed back end for it. I'm aware of mssql.django-pyodbc and django-mssql as unofficially supported back ends. Both proje...

SQL Server/ADO.NET: Locking issues

I understand this is a VERY vague question, so forgive me. A company I used to work for has contacted me saying that since they've upgraded to SQL Server 2008, they've been encountering a ton of "locking" issues. I really don't know what this means. I don't even know how to see these "locking" errors in SQL Server. This was not my area...

Using TSQLUNIT for SQL unit testing: don't you need to duplicate your SQL code?

Hi, I'm considering writing some unit tests for my Tsql stored procedures, I have two concerns: 1) I will have to write a lot of SQL to create test fixtures (test data prepared in _setup procedures) 2) I will have to "re-write" my query in the test procedure to obtain the results to compare against the results from the stored procedure...

How do I prevent SQL Server sysadmin users write access ?

I have created a test user that has sysadmin right in SQL Server 2005 (sysadmin, because i want to profile with this user name also).But i want to restrict that test users access rights to production database. It is under "logins" and also db name selected under the "User Mapping" tab of its properties with "db_denydatareader" default s...

What's a good online resource for SQL server and T-SQL?

Background: I have an interview some time next week (for a Jr position) that requires SQL Server. The job descriptions states "Must be able to score high in a C# and a SQL Server design test." I feel I'm solid on the C# portion, and I think I'm pretty good on implementation-agnostic DB design (Reread "Mastering Data Modeling" by Car...

SQL Combining several SELECT results

I have three SELECT statements that each return a total, 'New Cases', 'Closes Cases', 'Existing Cases'. How do I combine these so they are returned in one resultset. ie I need a table returned with 3 fields, 'New Cases', 'Closes Cases' and 'Existing Cases' each with one total SELECT COUNT(CaseID) AS 'New Cases' FROM dbo.Cl...

Does sql server check for duplicate GUID on insertion?

When inserting a guid as a primary key does the db server go through every single row to make sure there's no duplicate or does it just assume that a duplicate is not possible or very unlikely? with int the db server can simply increment the key but not the case with GUIDs ...

Generating keywords from a pdf automatically

My application allows user to upload pdf files and store them on the webserver for later viewing. I store the name of the file, location, size, upload date, user name etc in an SQL server database. I'd like to be able to programatically, just after a file is uploaded, generate a list of keywords (maybe everything except common words) an...

How to populate a database column with random numbers

How do I populate a int column, currently empty, with random numbers with no duplicates? ...

preserve primary key values in database

when i copy data from one table to another all the primary key values are resetted. is there a way to keep the values of the original table. in the original table the primary key values (int) are not continual (deleted rows) another table has all the values hardcoded thats why i need to keep the same values. ...

SQL Server 2008 installation error: Previous releases of Microsoft Visual Studio 2008

Hello everyone, I got this weird error which mentions I should install VSTS 2008 SP1, during the process of installation of SQL Server 2008 developer edition. But actually I have VSTS 2008 SP1 installed. Any ideas what is wrong? Here is my screen snapshot. http://i41.tinypic.com/9teo7m.jpg thanks in advance, George ...