sql-server

DATEPART as a parameter

I'm guessing this is not possible since the engine doesn't like it, but is there a way (barring dynamic SQL) to pass in a DATEPART as a parameter to a procedure? ...

SQL to dBase Query Translator?

Is anyone aware of an application that will allow me to convert some existing SQL queries into dBase? I have an application that I need to program but it prefers dBase queries to SQL queries. I've written a working SQL query, but now need to figure out what the query would look like in dBase. ...

SQL Server: how to get a database name as a parameter in a stored procedure

I'm trying to create a simple stored procedure which queries a sys.tables table. CREATE PROCEDURE dbo.test @dbname NVARCHAR(255), @col NVARCHAR(255) AS SET NOCOUNT ON SET XACT_ABORT ON USE @dbname SELECT TOP 100 * FROM sys.tables WHERE name = @col GO This does not seem to work cause I should put GO ...

Which isolation level to use to prevent data from being read?

I have situation like this. Query is like this. Select * from TABLE where ID = 1 (what a query :) after that I change stuff in that row and INSERT it with new id. I want to prevent other qeueries to read that first original row from query, untill I finish the read and insert. After that..go ahead. Basicly I want select and insert...

Best practice: How to detect if a SQL Server is available and failover if not

Hi there, I am looking for a way to detect if a SQL Server fails to respond (timeout/exceptions etc) so that if our C#/.net program trying to access the server asks a server that is down for maintenance, it will jump and try another automatically. I would like a solution where we do the SQL connection and THEN get the timeout. We could ...

What would this SQL query look like in dBase?

Can someone help me translate this query into a dBase equivalent expression? select top 300 * from CONTACT1 c1 left join CONTACT2 c2 ON c1.ACCOUNTNO=c2.ACCOUNTNO where KEY1='10INQA' and KEY2='2011 Fall' and c1.ACCOUNTNO NOT IN (select accountno from CONTSUPP where RECTYPE='E') ...

Stored procedure scope: using sp from another database

I hava a stored procedure named PROC_fetchTableInfo (simple select from sys.tables) in a database named Cust I would like use this procedure in a another database named Dept I tried to execute this sp in this database using command EXECUTE Cust.dbo.PROC_fetchTableInfo but as a result I get tables from the database Cust. How to g...

How to send a SQL Server Report as Word doc to BPOS SharePoint document library

Hi Everyone, I'm trying to determine how exactly to convert SSRS reports to Word docs and have them sent to the Sharepoint doc library. From my research, all I could gather was that it's all part of SS Integration Services, but little else. I'm not using report builder, but Visual Studio. Any help here would be highly appreciated. Tha...

Complex SQL I don't want to convert in a stored procedure

Hi all! I would like to have your assistance in order to know if it's possible to achieve the desired query without needing a stored procedure. I will try to explain myself as good as I can. I have a similar structure to this: PK / FK / DateTime / Value 1 / 68 / 10:30 / 60.5 2 / 68 / 09:30 / 10.5 3 / 61 / 05:30 / 01.0 4 /...

SQL Server deadlock while inserting rows in a table

Hi, The topic of sql server deadlock has been discussed many times, however, I was unsure that even two simultaneous inserts on a table can end up in a deadlock situation. Scenario: While testing our application (SQL Server 2005 as backend, ASP.net 3.5) we inserted records into a table simultaneously (simplified overview) and that resu...

Adding Excel Spreadsheet to SQL Database

How can I import an excel file into my SQL database? I have two options, MSSQL or MySQL. Thank you ...

SQL Server stored procedure error while executing from php

I am trying to execute a stored procedure from php. In the php code iam sending a integer parameter to the stored procedure $orderId =824; $result =mssql_bind($sp, "@orderID", $orderId, SQLINT1, true, false); I getting an error mssql_execute() [function.mssql-execute]: message: The formal parameter "@orderID" was not declared as an...

TSQL - SET vs. SELECT when assigning variables?

What are the differences between SET vs. SELECT statement when assigning variables in T-SQL? ...

Developer: how to get reporting data from about 20 databases?

I'm a junior developer in our team. In one project we have about twenty databases in one SQL Server instance. We have db_owner rights to these databases. My intention is to monitor certain things from these databases (e.g. file size). But because we don't have sysadmin rights, we don't have all those management tools for these database...

How to join two tables

Table1 Date v1 05/01/2010 26 05/02/2010 31 05/03/2010 50 Table2 Date v2 v3 05/01/2010 42 jkl 05/02/2010 28 mno 05/03/2010 12 pqr 05/04/2010 13 stv 05/06/2010 48 8965 How can I join the above two tables so that my result look similar to below Date v1 v2 v3 05/01/2010 ...

How do I count how many of these columns have a value in SQL?

Assume the following table: ID | Item1 | Item2 | Item3 | Item4 | Item5 ------------------------------------------ A | NULL | NULL | YES | YES | NULL B | NULL | NULL | NULL | YES | NULL C | NULL | NULL | NULL | NULL | NULL I want to return the following data set: ID | Count ------------ A | 2 B | 1 C | 0 Bas...

joining two tables

Possible Duplicate: How to join two tables table 1 Date StartingAum 07/01/2010 120 08/01/2010 220 09/01/2010 320 table 2 Date DepContr withdra 01/01/2010 60 15 02/01/2010 70 25 03/01/2010 80 15 04/01/2010 30 89 05/01/2010 40...

Is it possible for an SQL table to have zero columns?

I'm using the following query to gather information about a table's columns: SELECT COLUMN_NAME, ORDINAL_POSITION, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, Is_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'TableName' ORDER BY ORDINAL_POSITION If this query returns zero results, can I s...

Has Red Gate made any decision yet on if they will soon support GIT with Sql Source Control

Has Red Gate made any decision yet on if they will soon support GIT with Sql Source Control. GIT is becoming the defacto source control standard and I would hate to have to support GIT and SVN in order to use this slick RG product ...

SqlBulkCopy fails trying to copy a row with large content in an XML column

I am trying to copy a record from one SQL Server table to another. Both tables have the same structure, one of the columns is of type xml. Source table has a large xml content in of the rows, about 2.5Mb. I saved the content of the xml column into a file, see map.zip attached or download it from https://docs.google.com/leaf?id=0Bz4PXXE...