sql-server-2005

SQL Query hangs forever when joining on decimal(8,0) fields

Hi there. I have the following query, which works fine: SELECT TMP_CLPUD.dbo.FormatS(RIGHT(SV1.VASLOC, 7), 9, 0) AS C_ACCOUNT, TMP_CLPUD.dbo.FormatS(Cust.C_CUSTOMER, 7, 0) AS C_CUSTOMER, CA.OID, CN2.NBCUNQ AS CUNQ, CN2.NBSUNQ AS SUNQ, 'AC' AS C_STATUS, TMP_CLPUD.dbo.mmsDATE(CN2.N...

Sql Agent and Database mail is this what I need for email reminders?

Hi I want to use ms sql 2005 to send email reminders to my customers. I want to send daily reminders that should run around midnight(when traffic would be low). So I think the best way to do this is through ms sql 2005 and I been looking into sql agent and database mail but I am unsure how to make a script that would dynamically get th...

Query cost relative to batch is 100%

I'm not sure sure how to interpret this, but all the queries I run in sql server 2005 have a "query cost (relative to batch)" of 100%. Is there any way to reduce the cost? ...

How to store results from a query while in a stored procedure

Hi Say I have this great query in my stored procedure. Select * from Temp How would I store the results of this in the same stored procedure since in the next line I want to go through it in a loop(I don't know how to do this yet either) and do stuff to it. I found something like this DECLARE total_count INT DEFAULT 0 SET total_...

Check file existence from sql 2005 without needing SA permissions

Hi, I have been trying to get xp_fileexist in sql 2005 to run under a sql account without having to grant sysadmin permissions. The issue is that I am unable to get it to run otherwise - the value it returns is 0 despite knowing the file exists. Points to keep in mind: The share that the images/files are stored in is not local to the ...

How to stop Databasemail from executing

Hi I was playing around with a stored procedure and I think I made an endless while loop(I think I forgot to close the cursor) now it is sending me emails and I don't know how to stop it. How can I kill it? edit this is what I see when I do what remus told me to do Sorry I don't know how to output the results nicer. 1,0,2010-07-06 1...

How to obtain only ALL Undocumented Stored Procs in SQL SERVER 2005

If I write SELECT * FROM sys.all_objects WHERE ([type] = 'P'); I will get all the SQL Stored Procedure. But how to obtain only the Undocumented ones? Thanks ...

How to use a temporary table variable (e.g. @temp) for holding the result of sp_msforeachdb

I am basically trying to find out all the table of all the databases present in the SQL SERVER by using sp_msforeachdb. If I write exec sp_msforeachdb 'select "?" AS DatabaseNames,* from [?].sys.tables' I will get the result well but for every Database, a seperate record set will be created. Now if I use CREATE TABLE #DBINFO ( ...

SQL Server 2008 Remove Case Sensitive Check

Hi, i just installed SQL Server 2008 and imported AdventureWorksDatabase (for SQL 2005, as for 2008 that didn't worked). It is now enforcing case sensitivity when i searched for any tables, views etc Hence Person.contact table when written throws an error of Invalid column name, but when Person.Contact is written it shows all rows. Pl...

32bit OSQL issue with 64bit Windows+64bit SQL Server

I have a Windows 2008 x64 server and with SQL Server 2008 x64 installed. osql.exe under SQL Server directory could list instances with -L. I copied osql.exe+osql.rll from another SQL Server 2005 x86 and '.\osql.exe -L' returns error like "[ODBC Driver Manager] Data source name not found and no default driver specified". After check reg...

When i run aspnet_regsql, nothing is created in the db?

Hi, When i run the aspnet_regsql.exe tool to add membership, roles etc against my db nothing is created at all. I run the tool via the GUI, enter my server name, and SQL server Authentication details, enter the db name('Tasking_Test') and follow the steps in the wizrd. After it's finished, i fired up SSMMS 2005 and checked that it had...

SSAS: named queries

I must first admit that I'm new to Analysis Services but now must extend an existing complex cube with a new dimension. So its even difficult to tell where my problem is without saying that i dont even have a plan how to start. Ok, i will try to tell what i want to achieve. Given is a Datasourceview with a named calculation 'Returns'. I...

SQL Server 2005 Stored Procedure Dependencies

Hello I have a list of stored procedures and I'm trying to determine the order they should be implemented in. Is there a way to determine how the stored procedures are dependent on each other. I'm thinking that I could use sysobjects and syscomments. Thanks ...

SQL statement to select the value of the latest version of data based on the latest date

I have a simple query and am wondering if it could be more elegantly coded. The final solution has to be ansi-compliant. I need to fetch the latest value from a table based on date and version. A sample would explain more clearly: declare @t table (id int, due_date smalldatetime, version int, value nvarchar(10)) insert into @t select ...

Automated scripting of SQL Server schema changes

I'm working on a project where we are updating client databases from older version to newer versions of the database and the related schema. I'm looking for a way do the following for all of the tables in the database that our program uses. If the table doesn't exist create table else for each column in the table bring the col...

Development and Test Environment Best Practices?

This question is for ASP.NET and SQL Server developers. What are your best practices with respect to setting up your development and test environment? I'm interesting in the following issues: How many tiers do you recommend and what goes on on each tier? Just dev, test, and production or perhaps dev, test, staging, and production? W...

Can't seem to wire up a VS 2005 DataGridView in the IDE using SQL Compact Version

Using VS 2005, I've created a SQL Server Compact Version database, and filled a test table with data. (Also to clarify, I HAVE installed SQL Compact Version and the tools) I've dropped in a DataGridView onto my main form, created a new data source, and have even previewed the data. However, no matter what I try, each time the app runs...

SQL - displaying zero results

I am looking to display a 'O' or 'No results found' when no records are found based off my query but can't get it right. I think the problem comes from that I am trying to display information about the records I am counting along with how many there are that fit the criteria. Perhaps its not the count that I need to change with ISNULL ...

How do I add Hours, mins, seconds to dateadd sql?

Hi I want to get an entire date So today would be 7/7/2010 12:00:00 am to 7/7/2010 11:59:59 pm So that should be the full 24 hours since 12:00:00 am would be the 8th then. So I have this select DATEADD(??, ??, DATEDIFF(dd, 0, GETUTCDATE())) How do I make it add 23 hours 59mins and 59seconds to it? ...

Concatenate with ORDER PRESERVATION

I have a table tblSomeData OrderOccurance ID Data -------------- -- ---- 1 1 HTMedia 2 1 Hedge 3 1 Bowing 4 1 FonWirelessLtd The first column "OrderOccurance" indicates in which order the elements i.e. Data will appe...