This is an SQL Server 2000 question. Without having access to the "Design Table" option in the pop-up menu of a table, is there another way to see what constraints, indexes, primary key, etc. that a table has?
Holy MOLY I've been banging my head up against the wall on this matter for months now. I have two databases and I need to be able to see the tables from different different databases. Usually I create a view like this
LicensingActions.dbo.License_Suspensions
But it wasnt working kept telling me that the License_Suspensions table didnt exsist and at the time the name was in all caps. So I decided to change the name, and low and BEHOLD IT WORKS. The funny was that I wasnt having that problem any of the other tables just that one. Well live and learn. Just thought I'd share that with you guys
This is a new problem to me, I have been running SQL Server 2000 with VS 2003 and last summer upgraded to SQL Server 2005 with VS 2005 - (both evaluation copies) all was fine I bought the full upgrade of VS 2005 and SQL server dev edition in Dec 2006 and recently I have started to get a total system fallover dreadful noise followed by black screen and reboot. This happens only when I view the Table Data "Show Table Data" in "Server Explorer" in VS2005, viewing design is OK, stored prcredures OK I suspect this is either a hardware impending failure or software conflict but I would like some pointers please I am using XP Pro sp2 with 1GB ram, F Secure Internet security, the Database is hosted externaly
Hello, I'm Hernan I wonder if someone knows How to query the last table used date in sql server. Note that I'm interested in "used date", not "modification date".
HI all, we have a table that has it's primary key data type Bigint. Isthere any way with Access to view this table? I find it hard tobelieve that two tools from MS don't play nice with each other, may beI should.SQL Server 2005Access 2003TIA
I am using MSSQL 2000 and trying to debug a stored procedure that has a #temp table in it. I am using the .NET SQL debugger and I would like to display or view the contents of the #temp table while debugging. Does anyone know how to do this?
I know this is probably a flick of a switch but I cannot figure out which switch. Setup is SQL Server / Stored Procedures / DAL / BLL(skipped for testing) / PL. The stored procedure queries from only one table and two columns are ignored because they are being phased out. I can run the stored procedure and preview the data in the DAL but when I create a page with an ODS linked to the DAL and a GridView I get this error. I checked every column that does not allow nulls and they all have values. I checked unique columns (ID is the only unique and is Identity=Yes in the table definition). I checked foreign-key columns for values that are not in the foreign table and there are none. Any ideas why do I get this? Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
Hi, I am getting the above error when trying to load a report into my Web Application, I have tracked the error down to one specific field in my database. Even though this field is a NVarChar field and is of size 30 it would seem that there is an issue returning the value from the field. I can write it into the database no problems but when I try to get it out of the database it returns the above error. e.g MOB 401.908.804 - Fails 0401.907.324 - okay 8239 9082 (pager) - fails Anyone got an idea on how to fix this???? Regards.. Peter.
Can anyone recommend a good article/book on the subject? I am trying to find out more about compound primary keys. How many is too many? Does the number of primary key columns affect your performance? If so, how does it affect it? Should some of the constraints be handled from stored procedures?
I am new to MsSql. I want to know is there any command through which we can get all the consraints on a table or in a databases. In the same way how to get the all table names in a database from the coomand prompt or thorugh query analyzer.
I remember once using a command in Query Analyser that gave me all theinformation about a table. It showed details about the columns,constraints, keys, indexes etc.I can't remember how I did this? Can anyone help me?It could of been a stored proc that I called or a query on the systemtables.I do know that it was very simple to do and it was executed in QueryAnalyser.Can anyone help me?
Just started learning SQL recently.But one thing i'm still not clear on is about altering relationships betweentables after they've been created.Instead of creating a foreign key when the table is first created - i createthe table and then run a query to set the foreign key and relationship(one-to-one, one-to-many etc)Anyways, long story short is i want to create a one-to-one relationship witha table but am having problems with adding more than one constraint at atime when altering a table.Understand yet? Easiest thing to do is show you:I have 2 tables: Branch_Table and Employee_TableI want to create a one-to-one relationship between emp_id on theBranch_Table and manager_id on the Employee_Table.The SQL i've written which doesn't seem to work is:ALTER TABLE Branch_TableAdd Constraint Branch_Table_FK1 FOREIGN KEY (manager_id)Add Constraint Branch_Table_UQ1 Unique (manager_id)References Employee_Table (emp_id));Am having trouble with that second Add constraint (UQ1 unique). I know it'ssomething to do with the Add syntax above.So basically, my question is can i create a one-to-one relationship withjust the one SQL Query? And how would i do it?Many thanks in advance.
Is it possible to define a constraint for Primary Key on more than 1 column or an alternate index on a column in a return table from an inline table valed function?
Example Header:
alter FUNCTION [dbo].[fntMetaFrame] (@ii_CompanyID int)
RETURNS @tbl_MetaFrame TABLE ( pk_Key int Identity(1,1) primary key,
I need to script out data in several tables (30+) and then reload those tables on a different database. The "target" database table data will get overwritten each time, not appended to. Several of these tables have numerous foreign keys and other constraints that must be dealt with. None of them have more than 100 records or so. Then I need to keep this script in source control and reference it as part of a post-deployment step with a Visual Studio DB project.
I have redgate, dbghost and visual studio. Are there any tools will generate the script for me complete with dropping all the constraints, truncating the tables, then re-adding the constraints back? Or, am I looking at simply scripting the table data out, then modifying the script myself to add in the steps to drop/readd the constraints? Further, since some of these tables might have relationships, not just to other tables, but to those in question, there will likely be an order in which the tables need to get loaded.
The approach I am thinking will be needed, since ive done this sort of thing before except with SSIS, is to run something like dbghost or the "generate scripts" option in SSMS as a starting point. From there, change the order around as needed, etc.
I am testing Insert, Update etc. and messing up my database with "dirty" data. Is there a way to temporarily drop FOREIGN KEY constraints to truncate a table after testing without dropping the whole table and rebuilding it? Newbie
Hey there, Trying to build a temporary table based on a parent table such that:select * into #staging from tbl_parent where 1=0 The temp table (#staging) picks up any NOT NULL constraints from the parent (tbl_parent) table and frankly, it doesn't meet my needs.I also tried to build a view of the parent (tbl_parent) table from which to base my SELECT INTO and still, the constraints followed. I'm thinking perhaps it possble to iterate though the temp table using syscolumns sysobjects and and set the column NULL properties on the temp table AFTER its been created but in this approach, I'm working to avoid directly referencing the columns by name. Is this possible? A better answer perhaps? Purpose of exercie is to populate a record in memory before it hits the table.I'll be constructing the record on the fly so that at first, I won't have all the fields to de-Null the columns.Also, I don't wish to lose the fact that some of my fields are Null - once I've fully populated my temp record, I'll insert into my 'real' table and will depend on constraints to throw the appropriate error. In this I won't have to built custom error checking in the stored procedure itself but instead depend on SQL SERVERS built capacity to the throw the error. This opens a bunch of possibilities for extensibility since if at a later date a constraint rule changes, one need only change the parent table definition rather than cracking open the stored procedure. Thank you for reading and a big thanks to you for replying :) Also,
I'm working on creating a new version of an existing table. I want to keep the old table around, only with a different name. In looking this up I found there's a system routine named sp_rename, which looks like it will work fine.However in thinking about this I realized that the foreign key constraints defined on the table (there's 3 of them) are likely to not be renamed, correct?
If I'm correct, then I suppose I could rename the table, then drop the 3 foreign key constraints, and create them new using different names for those foreign key constraints.
How to delete records from multiple tables if main table’s entity is deleted as constraints is applied on all..There is this main table called Organization or TblOrganization.and this organization have branches which are in Brach table called tblBranch and this branch have multiple applications let say tblApplication and these application are used by multiple users called tblUsers.What I want is: when I delete the Organization All branches, application and users related to it must be deleted also.How I can apply that on a button click in asp.net web forms..Right now this is my delete function which is very simple
Public void Delete(int? id){ var str=”DELETE FROM tblOrganization WHERE organizationId=”+ id ; } And My tables LOOK LIKE this CREATE TABLE tblOrganization ( OrganizationId int, OrganizationName varchar(255)
I have an interesting problem to report that I'm hoping someone will be able to assist in solving.
I have a report that contains a table inside of a list. When I view this report on my local machine via Visual Studio, everything appears normal, the columns are all the correct size. However, as soon as I publish this report to the report server and attempt to view it via Report Manager, one of the columns expands horizontally!
From all of the documentation I have read, I understand that Reporting Services does not provide the ability for columns to expand horizontally, only vertically. Can anyone help explain why this is happening or a possible solution to turn this automatic expanding off?
I'm very new to SQL Server having previously worked with Oracle 10g for the last couple of years.
Anyway, in Oracle there is a view called V$SQL that provides information about SQL that is or has recently been executed. I'm trying to find a similar sort of functionality in SQL Server.
Basically, what I'd like to do is list all of the SQL statements that are running at a given moment. Or even better would be a way of listing all statements that have run in the last 10 minutes.
I just installed SQL Server on my 2003 box. Up till now I've been using MS Access for all my database needs. When I wanted to work on fields in a table, all I had to do was open Access and there you go. How do I view and modify Fields in SQL?
Is it possible to view the transaction log to identify events run against a database. I know that I could create a trace file to log events. But what I really want to know is whether there is any way to actually view the live .ldf transaction log file and make sense of it.
It is possible to do something similar in Informix.