How do I go about deleting a row that is referenced by many other tables, either as a primary key or as a foreign key?
Do I need to delete each reference in the appropriate order, or is there an 'auto' way to perform this in, for example, linq to sql?
thanks.
...
I have two tables (bank statement and client requests) where column [date] is type of DATETIME2(0).
I have to compare two records only by theirs Date parts (day+month+year), discarding Time parts (hours+minutes+seconds).
How can I dot that? I tried CAST and CONVERT but it didn't helped.
Update:
Marc_s's answer works
DATEADD(dd, 0, D...
Hi,
I have a table that looks like this:
id datatype name value
0 nvarchar(255) myName 'Paul'
1 int age '30'
2 float(53) Custom1 0.5
3 float(53) Custom2 1.3
4 float(53) Custom3 2.7
I am wondering if it is possible to do something like the following where I cast ...
Is there any inbuilt store proc / any database program by which I can generate all the database object script(like stored procs, triggers, functions, tables etc.) from a particular database.
I am using SQL SERVER 2005 + 2008
Thanks in advance
...
Hello,
I have a desktop client that is using the sync framework to synchronise the database to the server. I am experiencing problems occasionally with it "Cleaning up" the tables change tracking.
I did some research and found a post on the internet that gave some code that resets the anchors on the table and then resynchronises. This ...
I have a problem that I know is something local, related to transaction scope, probably MSDTC (I don't know very much about it).
The other project developer (same codebase, everything commited) executes the whole solution, but when I try to get some data from the database (not always), I have the following error:
The underlying provide...
A new feature in SQL Server Management Studio 2008 is 'outlining' (the ability to collapse regions). It is awesome. However, by default all regions are expanded. I can't seem to find a way to 'collapse all' (also called 'toggle outline' in Visual Studio). Is anyone aware of a way to do this? I've been tasked with reviewing a 3,000 l...
Can something like this be done with a select statement:
SELECT col1, concat(col2 + ' ') FROM ....
GROUP BY col1
I know i can use count(col2) or sum(col2) for integers but is there a function for concatenating if the type is nvarchar or nchar?
...
Can anyone think of a reason a SQL Server 2008 failover cluster couldn't use Cluster Shared Volumes for databases and log files?
It seems that using CSVs should reduce failover time and reduce the complexity of the cluster group configurations (the physical drive resources wouldn't need to "failover" anymore).
...
I am moving from SQL 2000 to SQL 2008. The SQL 2000 is on a Server 2003. SQL 2008 is on a Server 2008. I have imported my database successfully. I am able to perform queries and they work fine. I use a VB6 program running in the IDE to update the database.
When my VB6 program runs on a server 2003 the program will connect using the fol...
I have a number of type Decimal(8, 2) and have been using Substring to get fractional value.
E.g.)
declare @val decimal(8, 2), @strVal varchar(10)
set @val = 15.80
set @strVal = cast(@val as varchar)
select @val, substring(@strVal, charindex('.', @strVal), len(@strVal))
Is there a better way to simply get fractional value, .80 fro...
I have a sql server job, which has been disabled.
But the job continues to attempt to run at the original scheduled time.
I wonder why it keeps doing this.
Thanks!
...
I'm trying to test out the new table-valued parameter functionality of SQL 2008 by calling a stored procedure using ADO.NET, but I'm running into a problem where the parameter seems to contain no rows when it gets to the stored procedure. The UDT looks like this:
CREATE TYPE [dbo].[PersonType] AS TABLE(
[FirstName] [varchar](50) NULL,
...
I have a row in a table. This row has an ID column referenced in a few other tables with millions of rows. The SQL statement to delete the row always times out. From my design, I know the row I wish to delete is never referenced any where else. Hence I would like SQL to ignore having to check all other tables for a foreign key reference ...
I have both 'SQL Server Compact 3.5 Service Pack 1' and 'SQL Server Management Studio 2008' (SSMS) installed on my PC. In the past, I was able to select 'SQL Server Compact Edition' from the list of 'Server Types' in the 'Connect to Server' dialog within SSMS. This entry is now missing and I have not been able to restore it.
...
Since the answers did not really cover the problem, I posted this on ASP.Net and completly rephrased it. I will post the edited question here:
I have been using the attachDB connection string and I usually deploy to IIS. The site works fine, however, I made some changes to the database and the newest version would not copy as it said ...
I'm creating a Google map mashup and am using SQL 2008.
I will have a large number of points on the earth and will want to perform various calculations on them in SQL - such as selecting all points contained within a particular polygone, or select all points within 10km of XY.
I have never used and SQL spatial features before. Should I...
My client is using Advantage Database Server and wants to move to SQL Server but obviously wants to move all his clients data as part of the upgrade over to SQL Server.
I've thought about writing an app to do the transfer but thinking it might be more trouble than its worth.
What would you recommend?
...
The company I am working for is looking to switch platforms from ColdFusion 8 / Windows to Ruby on Rails / Linux. Our database solution will remain as MSSQL 2008 on Windows. I will likely follow up with a series of questions relating to this migration separately, but for now I have a MSSQL & Rails specific question.
Back in 2006 when I ...
Good day,
When creating a new table in SSMS - right click on the "Tables" node, choose "New Table..." - the default definition for a new column is nchar(10).
Can I change that? Let's say I would like the default column definition to be varchar(5) whenever someone creates a new table.
I can't find any sort of option to change that, I'...