sql-server-2005

Exchange 2003 as a SSIS data source

Hi all, I am new to stackoverflow, and this is my first question: I would like to create a SSIS task on SQL 2005 server that queries a specific email account on an Exchange 2003 server, and creates a report. The report currently contains the amount of emails received, average time of reply, and emails with reply time that have gone ov...

How to retrieve record from SQl using Date as parameter.

in my table am storing one column(smalldatetime). i need to retreive records by giving just date- and search the column specified above. Ex: 10/6/2010 4:01:00 PM - this is the actual value in Column. And i just want to search records from table by givin today's date. ..??? ALTER PROCEDURE [dbo].[spDisplayAllOpenPrepaidSales] @pr...

Compare when value could be both NULL or text

Now I know you can't directly compare NULL to anything (as null is unknown) so how would I achieve the following: select * from Material as m where MtrlCode = 826 and Exposlimit <> 'compareMe' Where Exposlimit MAY be NULL or it may not be. 'compareMe' may also be NULL. Therefore how do I compare the two? Bo...

Default table lock hint on SQL Server 2005/2008

How do you look up a default global table locking hint? -- Questions Are there any DMV/DMF (Dynamic Management View/Function) that return such information? And also, is there a way to change the default lock hint? Currently I am adding nolock hint almost everywhere to prevent locks. I'd like to avoid doing so by changing the d...

How come I can't see rows in sysobjects for objects that I know exist?

I am a member only of the db_datareader role on a database, and I cannot see rows in sysobjects for stored procedures that I know exist. Additionally, in SQL Server Managedemnt Studio, expanding the Programmability -> Stored Procedures node in Object Explorer does not show any stored procedures. Is this due to insufficient permissions?...

SQL - Order after filtering

How can I order the data and then filter it in TSQL (SQL Server)? I've tried something like this: SELECT [Job].*, ROW_NUMBER() OVER (ORDER BY [Job].[Date]) AS RowNum FROM [Job] ORDER BY Rank WHERE RowNum >= @Start AND RowNum < @End Doesn't work. I also tried to use a subquery, which throws: The ORDER BY clause is invalid ...

Need to move SQL Server 2005 Table storing Lat;Lng as varchar to Spatial ?

I have read some articles about using spatial optimized tables. Actually I use stored latitude and longitude as varchar comma-separated (lat;lng). Could you suggest the best way to perform this change and enumerate the advantages. It's really necessary for a large project or only move to SQL Server 2008? thanks. ...

Does SQL Server 2005 Log Shipping replicate changes to the master database schema and permissions?

In a SQL Server 2005 database that is replicated using log shipping, will changes to the following be automatically reflected in the replicated database? Tables Stored Procedures Views Functions Object-level permissions Database roles ...

Why is this LINQ so much slower than its SQL counterpart?

I have the below LINQ to SQL method that takes an inordinate amount of time to execute yet its SQL counterpart is quite simple and fast. Am I doing something wrong in the LINQ part? I am just trying to return some data to display, read-only, in a Data Grid. I understand that if the tool doesn't fit don't use it and as such I could j...

Select all records created or modified after a specific date in all tables in a SQL Server db

I would like a list of all new or modified records created after a specific date in all tables in a SQL Server database. I am using SQL Server 2005 and ssms. Is there a way to do this with one query, or some other tool? How could I do this for one table? ...

Retrieving SQL Relationships as a comma delimited string

Hello, I have a SQL Server 2005 database with two tables: Order, LineItem. Each LineItem has a field called LineItemID and OrderID. I have a query that is getting all of the Order records in my database. With each Order record, I would like to retrieve a comma delimited list of LineItemIDs associated with the Order. Is there a way to d...

Stored Procedure return multiple result sets

I need a SP to return multiple sets of results. The second set of results would be based on a column of the first set of results. So: declare @myTable1 table(field0 int,field1 varchar(255)) insert into @myTable1 select top 1 field0, field1 from table1 declare @myTable2 table(field0 int,field3 varchar(255)) insert into @myTable2 selec...

Constraints in SQL Database

I need to have a table in T-SQL which will have the following structure KEY Various_Columns Flag 1 row 1 F 2 row_2 F 3 row_3 T 4 row_4 F Either no rows, or at most one row can have the Flag column with the value T. My developer claims...

T-SQL between periods gaps

Hi, I have some data on my table like: DAY | QTY | Name 1/1/2010 | 1 | jack 5/1/2010 | 5 | jack 2/1/2010 | 3 | wendy 5/1/2010 | 2 | wendy my goal is to have a SP requesting a period of time (example: '2010-1-1' to '2010-1-5'), and get no gaps. Output example: DAY | QTY | Name 1/1/2010 | 1 | jack 2/1/2010 | 0 |...

Query to find all FK constraints and their delete rules (SQL Server)

In SQL Server 2005, can I issue an SQL query to list all FK constraints on tables within the DB, and show the delete rule? (ie nothing, cascade, set null, or set default) The output I'm looking for is something akin to: FK_NAME ON_DELETE ================================== FK_LINEITEM_STATEMENT CASCADE FK_ACCOUNTREP_...

questions on copying SQL Server database

Subquestioning [2] While copying Resource.mdf [1], I noticed that: 1) It is possible to copy Resource.mdf without stopping SQL Server instance (I attached one having copied from running instance and it works after attaching) . 1a) Should I understand that it as general possibility for all read-only databases or is it only in some v...

sql server agent proxy account

Hi, I am trying to use proxy account for non sysadmin to grant them exec permission on xp_cmdshell. What I did is: USE [master] GO CREATE CREDENTIAL [proxyaccount] WITH IDENTITY = N'domain\user', SECRET = N'password' GO USE [master] GO CREATE CREDENTIAL [proxyaccount] WITH IDENTITY = N'domain\user', SECRET = N'password' GO USE [msdb] ...

A Database Tool to check changes happened overnight and upload to MasterDB

HI I have 5 different database and a Master DB with same Schema .I am looking for a tool which can check any changes( new row insertion ) has happened since my last update and Sync with my Master DB . Is there any tool available for this ...

Using the result of an Stored procedure in a Select statement

i have an stored procedure wich return a Dataset(Table) how i can use the result of this stored procedure in a select statement? i need something like this Select T1.* from Dummy T0 INNER JOIN (EXEC [dbo].[SPGetResults] '900',300,'USD') T1 ON T1.aKey=T0.aKey i ' am using sql server 2005 ...

Using GO in SQL Server 2005

I am working on SQL Server 2005 and I have come accros the issue that I have run the multiple update query on the single table one by one. As it takes lots of time to execute one by one I came to know that by using "GO" I can run the query one by one. Like this Update Table A .... GO Update Table A GO Update Table A I am not sure ...