I have the following table. When i try to insert records using LINQ to SQL it works fine until I try to insert a record where the UserId is null. When I try that I get the following error
"UNIQUE KEY constraint Cannot insert duplicate key in object"
I am only trying to insert 1 record and the table is empty so there is definitely no cl...
Recently I have been working with a SQL Server database and I was trying to create some triggers for some tables using SQuirreL SQL Client and for some reason I was unable to get rid of the following pesky error message:
"Error: 'CREATE TRIGGER' must be the first statement in a query batch.
SQLState: S0001
ErrorCode: 111"
The query I ...
We have a table called table1 ...
(c1 int indentity,c2 datetime not null,c3 varchar(50) not null,
c4 varchar(50) not null,c5 int not null,c6 int ,c7 int)
on column c1 is primary key(clusterd Index)
on column c2 is index_2(Nonclusterd)
on column c3 is index_2(Nonclusterd)
on column c4 is index_2(Nonclusterd)
on column c5 is index_2(...
Suppose I am calling a query "SELECT name, city, country FROM People". Once I execute my SqlDataReader do columns come in the same order as in my sql query?
In other words can I rely that the following code will always work correctly:
SqlConnection connection = new SqlConnection(MyConnectionString);
SqlCommand command = new SqlCommand(...
How To detect the suspect database in SQL server2000 With Script Or Program ?
...
Given a Stored procedure, I want to extract the parameter from it.
How can I do this in .net?
...
When designing a database, what decisions do you consider when deciding how big your nvarchar should be.
If i was to make an address table my gut reaction would be for address line 1 to be nvarchar(255) like an old access database.
I have found using this has got me in bother with the old 'The string would be truncated'. I know that ...
Hi folks,
In my sql code i'm passing around a bunch of magic numbers :-
AnimalType TINYINT
/*
AnimalType can be one of the following :-
1. Cat
2. Dog
3. Bird
....
*/
Is there anyway i could make this a custom type / enumeration.
eg.
AnimalType ANIMAL
and it's constrained to contain a number between 1 <-> whatever (eg. 3...
Hi
I have tried uploading a transparent PNG image to a SQL server image field, and retrieving it using the DynamicData ImageHandler. The Transparent areas in the image appear white upon rendering. Please advise about any solutions
...
Update:
I tried to run this on a local instance of sql-server and sadly it worked!!!
now I know that the code is right and there is some kind of DBA restriction I need to find (and ask the DBA to remove)
Any ideas?
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
na...
I was wondering what would be the consequences of setting NVARCHAR fields to MAX instead of a specific size in SQL Server 2008, and limiting the input from the application's logic. Also, would these be a bad design practice?
...
I need to connect to a secure SQL Server database using Perl DBI. I need to find a way to authenticate the user securely (without fear of eavesdropping, and without storing passwords on the client side). I'm using SQL Server 2008 on Windows Server 2008, and Perl 5.10 on XP.
SQL Server supports encrypted connections via something calle...
Running into a problem.
I have a table defined to hold the values of the daily treasury yield curve.
It's a pretty simple table used for historical lookup of values.
There are notibly some gaps in the table on year 4, 6, 8, 9, 11-19 and 21-29.
The formula is pretty simple in that to calculate year 4 it's 0.5*Year3Value + 0.5*Year5Val...
We have a SQL Server stored procedure that runs fine in SQL Manager directly, does a rather large calculation but only takes 50-10 seconds max to run.
However when we call this from the .NET app via a data adapter it times out. The timeout however happens before the timeout period should, we set it to 60 seconds and it still times out ...
When you use a SqlDataReader, is the return set completely determined by the ExecuteReader step, or can you influence what you get by writing to the source table(s) while reading? Here is an example in very rough pseudo code.
sc = new SqlCommand("select * from people order by last, first",db) ;
sdr = sc.ExecuteReader() ;
while (sdr.rea...
I've tried searching through search engines,MSDN,etc. but can't anything. Sorry if this has been asked before. Is there any performance difference between using the T-SQL "Between" keyword or using comparison operators?
...
Hello all. I am just throwing this out for thoughts from the community.
We are creating an installer for a web application that will be installing our web application and provisioning a database. The database can be on the web server or a remote machine. We will also give the users an option to point to an existing database. The ins...
I've seen a few web searches and responses to this but it seems they all involve views.
How can I adjust a column so that it only allows NULL or a unique value?
In my case there's a table with stock items in which only the server items have a serial number. The rest are null. I would like to enforce some kind of control against enterin...
Are there any good technical solutions for extremely long term archiving of data, for example for 25 to 100 years?
Somehow I just don't have a lot of confidence that a SQL 2000 backup file will be usable in court cases or for historians in 25 to 100 years.
This is a customer requirement, not just speculation.
This is comparable to try...
I have a query that looks like
SELECT
P.Column1,
P.Column2,
P.Column3,
...
(
SELECT
A.ColumnX,
A.ColumnY,
...
FROM
dbo.TableReturningFunc1(@StaticParam1, @StaticParam2) AS A
WHERE
A.Key = P.Key
FOR XML AUTO, TYPE
),
(
SELECT
B.ColumnX,
B.ColumnY,
...
FROM
...