sql-server

Start SQL Server Jobs when field = specific value

I don't know if this is even possible, so i would appreciate any ideas, even those outside of Sql Server 2005, on how this might be accomplished. I have a linked server set up to a remote mainframe and I have a simple import job that runs overnight. The problem is that the table on the mainframe that the import needs to come from is just...

Building a non sequential list of numbers (From a large range)

Hi All, I need to create a non sequential list of numbers that fit within a range. For instance i need to a generate a list of numbers from 1 to 1million and make sure that non of the numbers are in a sequential order, that they are completly shuffled. I guess my first question is, are there any good algorithms out there that could he...

Transaction log has huge growth after backup

I am a programmer, with a side job as an involuntary DBA. I have a maintenance plan that does a full backup and a 'check database integrity' every night. I backup transaction logs every 10 minutes. The transaction log backup size spikes after the database backup - exponentially bigger. I used to rebuild indexes and statistics every n...

Can we use "if else" in "Check" constraint in sql server

Can i use if else under a check constraint. Can i use check constraint using a variable need xplanation with eg. ...

SQl Management Studio - Find "Rows Affected" BEFORE running Update Statement...

Before running an Update statement in SQL Server Management Studio, I'd like to see how many rows it is going to affect so I know my logic is sound. Any way to do this? I've tried running an execution plan a few times, and after running when I hover over the green update icon it shows rows affected, but sometimes it shows 20.5 rows fo...

Profiling Microsoft Dynamics SL 7 (Solomon) performance issues.

We are using Microsoft Dynamics SL 7 (Solomon) and are having performance issues when logging into the application and pulling up information associated with accounts. Aside from a very generic approach to diagnosing the problem(s) such as running SQL Profiler, I was wondering if there was an SL specific approach to discovering performa...

Troubles pulling id from first insert done by stored procedure to do use on second stored procedure

I'm having troubles pulling the id from the first insert to use on the second insert. Here's my SQL (I'm using stored procedures): DECLARE @JoinDate date DECLARE @ID int SET @JoinDate = getdate() EXEC Members_Add $(UserID), '$(UserName)', @JoinDate, '$(firstname)', '$(lastname)', NULL, '$(Country)', NULL, '$(stateorprov...

How to alter a DateTime field when it is updated?

Is there a database level function (trigger or something) that I can use to alter a DateTime field when new data is inserted? The issue is that a service I am integrating with happens to send out all of its times (in this case the time some info was received on their end) in GMT. I need to automatically change this to reflect the time ...

How can I see the SQL generated by EF db.entityset?

I have something like this in a repository: var results = db.EventSet.Include("Events") .Include("TestResults") .Include("Events.Donors") .Include("Events.DonorPanels") .Include("Events.Locations") ...

What is largest free datababase for SQL Server engine available for testing purposes?

What is largest free datababase for SQL Server engine available for testing purposes? ...

Extract name and prename from email address?

Question: I have a table with the columns ID, Name, Prename, Mail Mail contains the e-mail address of a person, for example [email protected] Now I need to check whether Name='' or Prename='' and extract "John" from Mail and put it into Prename, and put "Doe" into column Name Can i do that with SQL, if yes how ? I use MS-SQL 2005 ...

SQL Server 2008: Creating dynamic Synonyms?

Hi folks, in my SQL Server 2008 database I have a number of different tables with the same structure. I query them in different stored procedures. My first try was to pass the table name to the stored procedure, like: CREATE PROCEDURE MyTest @tableName nvarchar(255) AS BEGIN SELECT * FROM @tableName END But we can't use parameter...

Union and order by

Consider a table like tbl_ranks -------------------------------- family_id | item_id | view_count -------------------------------- 1 10 101 1 11 112 1 13 109 2 21 101 2 22 112 2 23 109 3 30 101 3 31 ...

Sql-server Full Text CONTAINS + COLLATE to ignore accents issues

Hi all im struggling a little here with using COLLATE to ignore accents whilst also using Contains full text. Ive reduced the columns im searching down to just one for the example here, and im hard coding the actual parameter just to simply this until i understand it. If i have SELECT Col1, Title COLLATE SQL_Latin1_General_...

How do I find the data directory for a SQL Server instance?

We have a few huge databases (20GB+) which mostly contain static lookup data. Because our application executes joins against tables in these databases, they have to be part of each developers local SQL Server (i.e. they can't be hosted on a central, shared database server). We plan on copying a canonical set of the actual SQL Server ...

SQL Server trigger doesn't fire when a record is inserted from ASP.NET web page

Hi Gurus! I have a wierd problem. I am having a web application developed in ASP.NET, the database is SQL Server Express 2005. I have written a trigger which updates another table's column value when a record is inserted or update. The two tables are InvtVendorInvoices (The trigger is on this table, trigger name is OnAlter_Ve...

In SQL Server, how can I find everywhere a column is referenced?

Within my rather large database, I would like to find out everywhere a column is referenced within the entire schema (SPs, functions, tables, triggers...). I don't want to just do a text search since this will pick up comments and also will find similarly named columns from other tables. Does anyone know if/how I can do this? I use ...

Classic ADO and Table-Valued Parameters in Stored Procedure

Is there some way to pass a table-valued parameter to a stored procedure in SQL Server via classic ADO? ...

Query Concatenated Field (using SubSonic)

Is there a way to query against a concatenated field using MS SQL? For instance, what I want to do is something like: Select FirstName+' '+LastName as FullName from Attendees where FullName like '%Joe Schmoe%' The above doesn't work. What I have found works is: Select * from Attendee where FirstName+' '+LastName like '%Joe Schmoe%' ...

Why OPENXML only returns one element

Can somebody explain me why this T-SQL code only returns one row with the value "1"? I was expecting to get two rows ("1" and "2"). Am I missing something here? DECLARE @XMLDoc2 XML SELECT @XMLDoc2 = '<ids><id>1</id><id>2</id></ids>' DECLARE @handle2 INT EXEC sp_xml_preparedocument @handle2 OUTPUT, @XMLDoc2 SELECT * FROM OPENXML (@ha...