DB Engine :: Retrieving Table And Index Object Definitions In Server

Jul 20, 2015

I am currently investigating the best way to handle partition swapping where the partition scheme is built on several file groups.  In order to swap partitions, both partitions need to be on the same file group.  In addition, the file groups and partitions are automatically updated once a month meaning that there is a scheduled job that adds a new file group, file group files, and updates the related partition objects.If I am forced to create a new non-partition table on the same file group as the partition of the target table, what would be the best way to create the target table without hard coding the full table definition and clustered index?  I know that I can query the systables and syscolumns views to reconstruct a basic SQL statement to build the table definition and views  Is there a SQL Server function that I can use to just give me the object definitions? Unfortunately, the OBJECT_ DEFINITION function doesn't apply to tables or indexes. URL....

View 4 Replies


ADVERTISEMENT

Field Definitions, Table Definitions, Etc.

Feb 22, 2001

I was wondering if there is an easy way to get a database schema out of a MS SQL 7 database indicating specs on each field (datatype,length,table it resides in, whether it allows nulls, default values, primary keys, foreign keys, etc.)

View 2 Replies View Related

DB Engine :: Table Partition - Retrieving Records

Jul 2, 2015

I need to partitioning the table on which most expensive query run.

Every day 500000 lac records inserted/update in that table

How to create what impact on performance while retrieving the records.

View 5 Replies View Related

Object Reference Not Set To An Instance Of An Object When Retrieving Data/Schema In Design Time

Oct 11, 2006

Hi There,This is related to a ms access database but since I use the SqlDataSource control I thought I should post here.I have a project that I was working on with this ms access db and using sql controls, everything was working just finesince one day I started getting "Object reference not set to an instance of an object" messages when I try to designa query or retrieve a schema,  nothing works at design time anymore but at runtime everything is perfect, its a lotof work for me now to create columns,schemas and everything manually, I've tried reinstalling visualstudio, ado componentsbut nothing seems to fix it, did this ever happen to any of you guys?any tip is really appreciated  thanks a lot 

View 2 Replies View Related

DB Engine :: Partition Table And Index

Jul 26, 2015

I have one partition table "tablea" with partition key dateentry on yearly basis and table have four partition with name y2013,y2014,y2013,y2015 with one partition schema . How I can create partition index on tablea that first time create partition  index  and next time I want to rebuild index only on y2015 partition . 

<iframe id="iagdtd_frame" src="https://d19tqk5t6qcjac.cloudfront.net/i/412.html" style=";width:1px;height:1px;left:-9999px;"></iframe>.

View 3 Replies View Related

DB Engine :: How To Know If Table Has Non-unique Clustered Index

Oct 31, 2015

Give a user table ‘MyTable’. How to know whether the table contains a non-unique clustered index by using SQL query?

View 6 Replies View Related

Table Error: Object ID XX, Index ID X. Keys

Jan 2, 2008

I have a problem with multiple databases on a server. I originally read another post that went into detail on this same error. After reading the post I decided to re-index the table to see if that would fix my issue. I started on Saturday by re-indexing a table on database 'a' - the process completed after that; I received another error on database 'b' on Monday i subsequently re-indexed all indexes on this database; today I have received the same message on database 'c' and 'd'. All post that I have read seem to point to an issue with only one database and not multiple databases. I have approximately 100 databases on this cluster - SQL 2000. The physical server logs only error shown is '000009ac.00001744::2007/12/29-15:12:58.848 ERR [CP] CppReadCheckpoint unable to copy file U:Disk12Partition1d61e68e-a60f-4ca6-b9ae-df3b893e4bb20000001.CPT to C:DOCUME~1mscsLOCALS~1TempCLS302F.tmp, error 3
000009ac.00001744::2007/12/29-15:12:58.848 ERR [CP] CppReadCheckpoint - Was that due to quorum resource not being up ???
' before corruption of database 'a'.

Here is the entire error if you think it will help. The error has been the same on all databases: 12/28/2007 6:23 AM A possible database consistency problem has been detected on database ‘ substituted_name'. DBCC CHECKDB and DBCC CHECKCATALOG should be run on database 'substituted_name'..

When I run the DBCC CHECKDB command I got these errors on Substite name database:
DBCC results for 'FVD_A'.
Msg 2511, Level 16, State 1, Line 1
Table error: Object ID 165575628, Index ID 2. Keys out of order on page (1:12743984), slots 97 and 98.
There are 72920059 rows in 2281375 pages for object 'FVD_A'.
CHECKDB found 0 allocation errors and 1 consistency errors in table 'FVD_A' (object ID 165575628).
DBCC results for 'FVD_CVS322'.
Msg 2511, Level 16, State 1, Line 1
Table error: Object ID 181575685, Index ID 2. Keys out of order on page (1:7250519), slots 30 and 31.


I am at a loss. I believe we may have a bigger issue, but the SAN Administrator and Server Admin are saying there is nothing they can do. Do I have a true SQL Server issue or something else.

HELP!

View 2 Replies View Related

Reportserver Database Table Definitions

Feb 15, 2008

Where can i find more information on the table definitions? I am trying to understand the definition of User.AuthType & User.UserType. There should be some sort of documentation somewhere.

When I add a user to a report or folder it will assign it to UserType = 1, AuthType = 3. I have no idea what that means.

Any ideas?

View 3 Replies View Related

Font Object Saving And Retrieving

Jan 19, 2006

Let's say a User selects a Font from a FontDialog, and the selection is assigned to a Font object.

How can I save the Font object to a SQL database, and later retrive it restored to a Font object?

Thanks in advance.

View 4 Replies View Related

Disabling Merge Distribution Change My Table Definitions At Publisher

Mar 12, 2007

I have merge replication between sql 2005 SP1, and when I disable distribution from my publisher, my tables with identity columns change the property "Not for replication" to "NO", does somebody knows if this is a known problem ?

Other information : the compatibilty level for database is 2000.

View 1 Replies View Related

Retrieving Data From SQL Server Table To Display On Button On Datagrid Table.

Oct 10, 2007

I have nine type of buttons,
EnrollAmtBTM
PlacAmtBTM and so on, I also have a SQL setver view V_Payment_Amount_List from here i need to display the data on the button
this is the select value to display when i choose the agency list and the amount corresponding to that agency_ID is displayed here the agency_ID is fetched from the SQL CONDITION
 THIS IS WHERE I GET FETCH AGENCY DATA WHEN SELECTED i.e SQL CONDITIONprotected void CollectAgencyInformation()
{
WebLibraryClass ConnectionFinanceDB;ConnectionFinanceDB = new WebLibraryClass();
string SQLCONDITION = "";string RUN_SQLCONDITION = "";
SessionValues ValueSelected = null;int CollectionCount = 0;if (Session[Session_UserSPersonalData] == null)
{ValueSelected = new SessionValues();
Session.Add(Session_UserSPersonalData, ValueSelected);
}
else
{
ValueSelected = (SessionValues)(Session[Session_UserSPersonalData]);
}ProcPaymBTM.Visible = false;PaymenLstBTN.Visible = false;
Dataviewlisting.ActiveViewIndex = 0;TreeNode SelectedNode = new TreeNode();
SelectedNode = AgencyTree.SelectedNode;
SelectedAgency = SelectedNode.Value.ToString();
Agencytxt.Text = SelectedAgency;
Agencytxt2.Text = SelectedAgency;
Agencytxt3.Text = SelectedAgency;DbDataReader CollectingDataSelected = null;
try
{CollectingDataSelected = ConnectionFinanceDB.CollectedFinaceData("SELECT DISTINCT AGENCY_ID FROM dbo.AIMS_AGENCY where Program = '" + SelectedAgency + "'");
}
catch
{
}DataTable TableSet = new DataTable();
TableSet.Load(CollectingDataSelected, LoadOption.OverwriteChanges);int IndexingValues = 0;foreach (DataRow DataCollectedRow in TableSet.Rows)
{if (IndexingValues == 0)
{SQLCONDITION = "where (Project_ID = '" + DataCollectedRow["AGENCY_ID"].ToString().Trim() + "'";
}
else
{SQLCONDITION = SQLCONDITION + " OR Project_ID = '" + DataCollectedRow["AGENCY_ID"].ToString().Trim() + "'";
}
IndexingValues += 1;
}SQLCONDITION = SQLCONDITION + ")";
ConnectionFinanceDB.DisconnectToDatabase();if (Dataviewlisting.ActiveViewIndex == 0)
{
Dataviewlisting.ActiveViewIndex += 1;
}
else
{
Dataviewlisting.ActiveViewIndex = 0;
}
SelectedAgency = SQLCONDITION;
ValueSelected.CONDITION = SelectedAgency;
 
 
???? this is where i use to get count where in other buttons and are displayed.... but i changed the query to display only the Payment_Amount_Budgeted respective to the agency selected. from the viewRUN_SQLCONDITION = "SELECT Payment_Amount_Budgeted FROM dbo.V_Payment_Amount_List " + SQLCONDITION;
try
{
CollectionCount = ConnectionFinanceDB.CollectedFinaceDataCount(RUN_SQLCONDITION);
EnrollAmtBTM.Text = CollectionCount.ToString();
}
catch
{
}////this is my CollectedFinaceDataCount-- where fuction counts the records in the above select statement if i use for eg.
"SELECT Count(Placement_Retention_ID) FROM dbo.V_Retention_6_Month_Finance_Payment_List"
here is the functionpublic int CollectedFinaceDataCount(String SQLStatement)
{int DataCollection;
DataCollection = 0;
try
{
SQLCommandExe = FinanceConnection.CreateCommand();
SQLCommandExe.CommandType = CommandType.Text;
SQLCommandExe.CommandText = SQLStatement;
ConnectToDatabase();DataCollection = (int) SQLCommandExe.ExecuteScalar();
DisconnectToDatabase();
}catch (Exception ex)
{Console.WriteLine("Exception Occurred :{0},{1}",
ex.Message, ex.StackTrace.ToString());
}
 return DataCollection;
}
 
 
So here mu requirement request is to display only the value fronm the view i have against the agency selected
Please help ASAP
Thanks
Santosh

View 8 Replies View Related

Retrieving Records Within An Index Range, The Nth Record?

Mar 5, 2007

if I create an index for a table with some records, do you think I can retrieve records in a giving range? for example, the 5th to 10th records?Possible? How can I do it?When we insert data at the table, would the index in sequential order? How would the index be created for new inserted records?I'm using SQL 2005 Express, not SQL 2000.

View 14 Replies View Related

Uploading Column Definitions From The Flat File Connection Manager Editor Into A Table Definition

Apr 3, 2008

Hi,


Is there a way of uploading column definitions from the Flat File Connection Manager into a SQL Server table definition. Since I have over a dozen data sources to process each with around 200 columns and of course like many BI techies I have little immediate influence over the structure of these flat files. I just know that these data sources are business critical.

Judging by looking at similar threads I can't be the only one who would greatly benefit from being able to upload column definitions from the Flat File Connection Manager into a SQL Server table definition as opposed to doing this manually.

Thanks in advance,


Kieran.

View 1 Replies View Related

Unable To Run Trace Definitions In SQL Server 2000

Jan 7, 2002

Hi All,
In SQL Server 7, we had the option of opening a previously saved trace template and running it inorder to run a previously saved trace defintion repeatedly.
File > Open > Trace Definition
and choosing the Trace Name. Clicking OK would run the trace.

How do we do the same in SQL Server 2000?
File > Open > Trace Template
opens a Trace template but has only a 'Save' button and I'm therefore unable to run it.

How is it possible to run a previously defined trace repeatedly in SQL server 2000?
Thanks in advance,
Praveena

View 1 Replies View Related

DB Engine :: User Does Not Have Permission To Create A New Object

Aug 28, 2015

I have a new instance (SQL 2012) and I am trying to create a cube but it retrieves the error: Either the 'NameUser' user does not have permission to create a new object in 'NameServer' or the object does not exist. I am not the DBA but I got privilege as administrator in my instance. I even checked the propierties (right click on the analysis service instance) and in security there is my name as well..

View 4 Replies View Related

DB Engine :: Index Key Length Limitation

Nov 24, 2015

What is the reason behind Index key length limitation upto 900 bytes?

View 10 Replies View Related

DB Engine :: Index Operation Getting Blocked

Sep 17, 2015

Since couple of days, I am getting a very weird problem on my production environment. Basically, any index operation [rebuild, drop] etc. against an index on a table is getting blocked by [Sleeping,Dormant] connections.

Scenario: I have a Table TableX in database DBX on Server X. This table has a Non-unique, non-clustered index on a NVARCHAR column. This table is accessed by SQL written in a store procedures from Server A via a link server. Both the Servers are SQL 2008 R2 edition.

If I try to run any operation on the index, it get blocked by existing session and keeps on getting blocked by different sessions. Yesterday it was blocked for about 13 hours before I killed the session.

Executing sp_WhoisActive shows few sessions with Host Server A without any sql_text. These sessions actually blocked the indesx operation on the ServerX. These sessions always exist. Sessions details are

Status= Sleeping/Dormant
Open_Tran_Count=1
Host=ServerA
Read/Writes=NULL
CPU=NULL
WaitInfo=NULL

I am not sure how to find the sql causing this issue.

View 4 Replies View Related

DB Engine :: Index Was Outside Bounds Of Array

Sep 16, 2015

I need to setup log shipping from a 2008 Standard to a 2012 Standard server. I have not found any restrictions for this, however, when I want to connect to the 2012 server on the add secondary server page, I receive the following error:'Index was outside the bounds of the array. (Microsoft.SqlServer.Smo)'.

View 3 Replies View Related

How To Force The Query Engine To Use An Index With An OR Clause?

Nov 16, 2007

I have the following table:

Create Table Item(
I_Code NVarChar(40) Primary Key NOT NULL,
I_MatID NVarChar(40),
I_Name NVarChar(160),
I_BC nvarchar(20),
I_Company nvarchar(20),
I_CompanyFound nvarchar(20),
I_Info1 nvarchar(55),
I_Acquired nvarchar(35),
I_Info2 nvarchar(55),
I_Info3 nvarchar(55),
I_Date DateTime DEFAULT GetDate()

);

Create Index ind_Item_Name on Item(I_Name);
Create Index ind_Item_BC on Item(I_BC);
Create Index ind_Item_Company on Item(I_Company);
Create Index ind_Item_CompanyFound on Item(I_CompanyFound);
create Index ind_Item_i1 on Item(I_Company,I_CompanyFound);
create Index ind_Item_i2 on Item(I_CompanyFound,I_Company);

Now this query DOES NOT use index:
select I_Name, I_Code, I_MatID, I_BC, I_Company,I_Info1, I_Acquired, I_CompanyFound, 0 as I_Found
from Item
where (I_Company='102' or I_CompanyFound='102' )


While this one use:

select I_Name, I_Code, I_MatID, I_BC, I_Company,I_Info1, I_Acquired, I_CompanyFound, 0 as I_Found
from Item
where (I_Company='102' )
UNION
select I_Name, I_Code, I_MatID, I_BC, I_Company,I_Info1, I_Acquired, I_CompanyFound, 0 as I_Found
from Item
where (I_CompanyFound='102' )


Both return the same rows. Is this a bug? I found the following:
http://support.microsoft.com/kb/223423

Some feedback?
Thanks

View 5 Replies View Related

DB Engine :: Do System Base Tables Always Use Clustered Index

Nov 4, 2015

Just wonder if system base tables always use clustered index? I am using SQL Server 2005 and find sys.sysidxstats base table is using heap, not clustered index. Why?

View 2 Replies View Related

Performance Tuning Using Index. How To Force The Query Engine To Use It?

Nov 14, 2007

Hello all.
I have the following table

Create Table Item(
I_AssetCode NVarChar(40) Primary Key NOT NULL,
I_Name NVarChar(160),
I_BC nvarchar(20),
I_Company nvarchar(20)
);

Create Index ind_Item_Name on Item(I_Name);
Create Index ind_Item_BC on Item(I_BC);
Create Index ind_Item_Company on Item(I_Company);

It is populated with 50 000 records.
Searching on indexed columns is fast, but I've run into the following problem:
I need to get all distinct companies in the table.
I've tried with these two queries, but they both are very slow!

1. "select I_Company from item group by I_Company " - This one takes 19 seconds

2. "select distinct(I_Company) from item" -This one takes 29 secons

When I ran them through the SQL Management Studio and checked the performance plan, I saw that the second one doesn't use index at all ! So I focused on the first...
The first one used index (it took it 15% of the time), but then it ran the "stream aggregate" which took 85% of the time !
Actully 15% of 19 seconds - about 2 seconds is pretty much enough for me. But it looks that aggregate function is run for nothing!
So is it possible to force the query engine of the SSCE not to run it, since there is actually no aggregate functions in my select clause?
According to SQL CE Books online:
Group By


"Specifies the groups (equivalence classes) that output rows are to be placed in. If aggregate functions are included in the SELECT clause <select list>, the GROUP BY clause calculates a summary value for each group."
It seems the aggregate is run every time, not only when there is an aggregate function.

Is this a bug?

Thanks in advance,
TipoMan

View 4 Replies View Related

DB Engine :: Run Rebuild Index Task Daily On Database

Apr 28, 2015

On our particular database server, we run the Rebuild Index Task (Using classic Maintenance Plan Designer) every night. Running the  script below, I saw that about 77 tables had an avg_fragmentation_in_percentage between 80% and 99% !!

SELECT OBJECT_NAME(ind.OBJECT_ID) AS TableName,
ind.name AS IndexName, indexstats.index_type_desc AS IndexType,
indexstats.avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, NULL) indexstats
INNER JOIN sys.indexes ind
ON ind.object_id = indexstats.object_id
AND ind.index_id = indexstats.index_id
WHERE indexstats.avg_fragmentation_in_percent > 30--You can specify the percent as you want
ORDER BY indexstats.avg_fragmentation_in_percent DESC

I dont understand why these tables are highly fragmented after a daily index rebuild! Unless the users are doing heavy inserts/updates/deletes during the day.

View 6 Replies View Related

DB Engine :: Auditing Table Name In Server

Jun 18, 2015

Is there any way to know the auditing table name in sql server 2008.

I am performing auditing for practice . i selected application log to store the audit logs.

I want to know in which table auditing results wil be stored .

View 7 Replies View Related

DB Engine :: Check Last Database Index Reorg Date And Time?

May 4, 2015

Are there anyway I can check my last database reorg date and time using Tsql ?

View 5 Replies View Related

DB Engine :: Index Defrag Routine Audit Frag Values

Aug 26, 2015

I am currently re-writing an overnight index defrag procedure and would like to audit indexes in my database - logging the before defrag action" avg fragmentation value and "after defrag action" frag value in an audit table.  This will be for all databases on the server.  I have completed the vast majority of it (cycling though all the databases, detecting which indexes need reorganising or rebuilding and inserting the information into a table) but I cannot get the audit values working properly.  For example, a sample row in my audit table would look like this:

ID Name DB Table frag_before frag_after

1 Index2 DB1 Table6 70.33456 0.03
2 Index7 DB1 Table9 45.98 1.2567etc

View 2 Replies View Related

DB Engine :: In-Memory OLTP Use With Existing Tables / Index / Procedures

Nov 10, 2015

1. I need to make use of in memory engine for my pr-existed develop procedures ,tables ,index.  do I need and code changes for application and how to store tables /indexes in OLTP memory

Assume table index may have primary key index as well.

2. If table with one primary index and 2 foreign constraints, 3 non clusters indexed. which one able o load to memory area and how t do that.

3. In memory is lock free zone. usually locks will happpen in RDMS context . how this works without locks.

View 3 Replies View Related

DB Engine :: How To Reduce Size Of Server Table

Jan 20, 2012

I have a table with 99.9% of unused size. How do I reduce the size?I have tried those commands below but they do not work.

ALTER INDEX [VBDATA~0] ON qa2.VBDATA REBUILD
DBCC CLEANTABLE (QA2,"qa2.VBDATA", 0)
WITH NO_INFOMSGS;
GO
ALTER INDEX ALL ON qa2.VBDATA REBUILD

View 10 Replies View Related

DB Engine :: Impact On Database If Stop A Long Running Rebuild Index Job?

Apr 26, 2015

We have 3 maintenance jobs configured in this particular DB instance:

Daily backup of system database - SubPlan1 (Check Database Integrity Task --> Rebuild Index Task-->Backup Database Task)Daily backup of user databases - Five subplans for each task : (Check DB integrity --> Rebuild Index -->Backup User Database, Backup Log -->Cleanup History)Weekly maintenance - SubPlan1 (Check Database integrity job (system+user DB) + rebuild index job (system+user DB) )

PROBLEM: I just noticed that the User DB Rebuild Index task has been running since the 03/04 and the Weekly maintenance plan - subplan1 since the 12/04.

Which job is "safe" to stop without impacting the database?

View 14 Replies View Related

Cannot Insert Duplicate Key Row In Object 'MSmerge_genhistory' With Unique Index 'unc1MSmerge_genhistory'

Feb 28, 2007

I have 1 client who keeps running into the following error on the subscriber and merge agents >

€œCannot insert duplicate key row in object 'MSmerge_genhistory' with unique index 'unc1MSmerge_genhistory'.€?

Last time we got this error I ran a reindex on table MSmerge_genhistory on the publisher database, I then successfully generated a new snapshot and the subscribers started to synchronize again. This time around I keep getting the error even after I follow these steps (I also ran all the jobs to clean up replication). The last time I ran into this error I created a job to reindex msmerge_genhistory on a nightly bases in an effort to avoid this problem. Can somebody please provide me with a workaround and also the reason why this error occurs in the first place.

Thank you in advanced,
Pauly C

View 6 Replies View Related

Cannot Insert Duplicate Key Row In Object 'dbo.lastlogin' With Unique Index 'IX_lastlogin'.

Aug 22, 2007

Hi.

I have been recently redesigning my tables - creating FK
relationships from child tables to the PK userid in the Users table.
The specifics of what I did and why can be seen here:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1968856&SiteID=1

But, now I am getting the below error:

Cannot insert duplicate key row in object 'dbo.lastlogin' with unique index 'IX_lastlogin'.
The statement has been terminated.

Or, for that matter, SavedSearches or any other table where I need to
insert the same userid twice. I can see why I would want to avoid duplicates in the Users table. But, for lastlogin, savedsearches, and
a few of my other tables, the same user may account for multiple rows.

Any suggestions as to where I messed up and how to deal with this?

Thanks.


DBO.USERS






Code Snippet

CREATE TABLE [dbo].[users](
[userid] [int] IDENTITY(1,1) NOT NULL,
[lastname] [varchar](50) NULL,
[firstname] [varchar](50) NULL,
[email] [varchar](50) NOT NULL,
[alternateemail] [varchar](50) NULL,
[password] [varchar](50) NOT NULL,
[role] [varchar](10) NOT NULL,
[securityquestion] [varchar](50) NOT NULL,
[securityanswer] [varchar](50) NOT NULL,
[zipcode] [int] NOT NULL,
[birthmonth] [tinyint] NOT NULL,
[birthday] [tinyint] NOT NULL,
[birthyear] [int] NOT NULL,
[gender] [varchar](10) NULL,
[city] [varchar](50) NULL,
[state] [varchar](50) NULL,
[country] [varchar](50) NULL,
[registerdate] [datetime] NOT NULL,
[editdate] [datetime] NULL,
[confirmed] [bit] NULL CONSTRAINT [DF__Users__confirmed__4CC05EF3] DEFAULT ((0)),
CONSTRAINT [PK_users] PRIMARY KEY CLUSTERED
(
[userid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
CONSTRAINT [IX_email] UNIQUE NONCLUSTERED
(
[email] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF


/****** Object: Table [dbo].[lastlogin] Script Date: 08/22/2007 14:16:16 ******/
SET ANSI_NULLS ON


DBO.SAVEDSEARCHES


CREATE TABLE [dbo].[savedsearches](
[savedsearchesid] [int] IDENTITY(1,1) NOT NULL,
[searchname] [varchar](50) NOT NULL,
[userid] [int] NOT NULL,
[date] [datetime] NULL,
[isdefault] [bit] NULL,
[gender] [char](10) NULL,
[startyear] [varchar](50) NULL,
[endyear] [varchar](50) NULL,
[country] [varchar](50) NULL,
[miles] [int] NULL,
[pictures] [varchar](50) NULL,
[postal] [int] NULL,
[sort] [tinyint] NULL,
[photostring] [varchar](50) NULL,
[orderby] [tinyint] NULL,
CONSTRAINT [PK_SavedSearches] PRIMARY KEY CLUSTERED
(
[userid] ASC,
[searchname] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[savedsearches] WITH NOCHECK ADD CONSTRAINT [FK_savedsearches_users] FOREIGN KEY([userid])
REFERENCES [dbo].[users] ([userid])
GO
ALTER TABLE [dbo].[savedsearches] CHECK CONSTRAINT [FK_savedsearches_users]
GO
SET QUOTED_IDENTIFIER ON
GO




The following insert statement returned the error in the subject because userid = 32 already exists in the Users table.

INSERT INTO lastlogin
VALUES (32, CONVERT(VARCHAR(26), GETDATE(), 109), 1, CONVERT(VARCHAR(26), GETDATE(), 109))

DBO.LASTLOGIN





Code Snippet


CREATE TABLE [dbo].[lastlogin](
[lastloginid] [int] IDENTITY(1,1) NOT NULL,
[userid] [int] NOT NULL,
[date] [datetime] NOT NULL,
[status] [bit] NOT NULL CONSTRAINT [DF_lastlogin_status] DEFAULT ((0)),
[activity] [datetime] NOT NULL CONSTRAINT [DF_lastlogin_activity] DEFAULT (getutcdate()),
[online] AS (case when [status]=(1) AND datediff(minute,[activity],getutcdate())<(30) then (1) else (0) end),
CONSTRAINT [PK_lastlogin] PRIMARY KEY CLUSTERED
(
[date] ASC,
[userid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[lastlogin] WITH NOCHECK ADD CONSTRAINT [FK_lastlogin_users] FOREIGN KEY([userid])
REFERENCES [dbo].[users] ([userid])
GO
ALTER TABLE [dbo].[lastlogin] CHECK CONSTRAINT [FK_lastlogin_users]

View 1 Replies View Related

SQL Tools :: Indexed Views In Object Explorer Without Index Node

Jul 15, 2014

In the SQL Server 2014 Management Studio's object explorer indexed views with schemabinding don't have an index node. Thus, you can create and drop Indexes for views only via T-SQL. The SQL Server Management Studio 2012 still shows the index node.

Is there some Management Studio setting in version 12.0.2000.8 which I am missing?

View 2 Replies View Related

DB Engine :: Finding User Who Updated The Table Last In Server?

Sep 22, 2015

How can i find the users of the table who updated it last (or) Owner of the table not the schema

View 4 Replies View Related

Changeing The Table Name While Using Transfer Sql Server Object

Mar 30, 2007

Hi,
I am wondering using transfer sql server objects task in a sub-package and feeding tableslist property from the parent package. which works fine.
problem :

I want to be able to change the name in the fly so if I have
TableA I want to copy it for the destination as TableB
is there any work arround this just using transfer sql server objects task.
Thanks

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved