Just using SQL Server 2000 built in features ONLY, what is the best way to handle special characters. I am not sure if Regular Expression could be used by purely using built in features? I would like to search and replace the special characters in my queries.
Thanks
...
I have a MVC web application with a table in the model that I would like to add to. I have the primary key set along with the other data fields, but every time I try to add to the table, I get the following error:
"Cannot insert explicit value for identity column in table 'TABLE_NAME' when IDENTITY_INSERT is set to OFF."
I'm not sure ...
help me please with a query.
Assume that we have a table with columns:
Transaction
StartTime
EndTime
Now, I need a query with computed column of (value = EndTime-Startime).
Actually I need to group Users(Transaction has a FK for Users) and sort them by average time spent for transaction.
...
Can I assign a value with EXISTS in the query. Currently it is giving me error Incorrect syntax near '='. But when I uses this query only it runs as expected.
IF EXISTS (SELECT @PK_LOGIN_ID=PK_LOGIN_ID FROM dbo.M_LOGIN
WHERE LOGIN_NAME=@LOGIN_NAME AND PASSWORD=@PASSWORD AND FK_ROLE_ID=@FK_ROLE_ID)
RETURN @PK_LOGIN_ID
...
Can someone give me the tsql to find also the dates that lie inside the give from and to date.
select * from empc where
DateFrom >= p_todate AND DateTo <= p_todate
What I mean is that dates in between should also be captured (I do not want to use BETWEEN syntax)
please help
...
I have a list of values extracted from a sql query in order to find out if x provided values are present in it.
SQL:
-Select null from table where code='x'
-resul.count>0
String:
-Loop for concatenating the codes in one string
-codesstring.Contains("x")
Hashtable:
-Loop for adding the codes to the hashtable
-codeshashtabl...
The team I'm on is currently writing code in TSQL to generate TSQL code that will be saved as scripts and later run. We're having a little difficulty in separating our unit tests between testing the code generator parts and testing the actual code that they generate.
I've read through another similar question, but I was hoping to get so...
I have a function that writes 3 lines into a empty table like so:
INSERT [dbo].[yaf_ForumAccess] ([GroupID], [ForumID], [AccessMaskID]) VALUES (1, 8, 1)
INSERT [dbo].[yaf_ForumAccess] ([GroupID], [ForumID], [AccessMaskID]) VALUES (2, 8, 4)
INSERT [dbo].[yaf_ForumAccess] ([GroupID], [ForumID], [AccessMaskID]) VALUES (3, 8, 3)
For ...
When should one rebuild indexes? Nightly? Weekly? Hourly?
...
Ok so I have this storedproc in my SQL 2008 database (works in 2005 too / used to) ...
CREATE PROCEDURE [dbo].[SetBinaryContent]
@Ref nvarchar(50),
@Content varbinary(MAX),
@ObjectID uniqueidentifier
AS
BEGIN
DELETE ObjectContent WHERE ObjectId = @ObjectID AND Ref = @Ref
IF DATALENGTH(@Content) > 5
BEGIN
...
Hi,
i have the following table.
CREATE TABLE [dbo].[Tree](
[AutoID] [int] IDENTITY(1,1) NOT NULL,
[Category] [varchar](10) NULL,
[Condition] [varchar](10) NULL,
[Description] [varchar](50) NULL,
CONSTRAINT [PK_Tree] PRIMARY KEY CLUSTERED
(
[AutoID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,...
Based on following table (I have kept spaces between the rows for clarity)
Path
-----------
\node1\node2\node3
\node1\node2\node3\node5
\node1\node6\node3
\node1\node4\node3
\node1\node4\node3\node7
\node1\node4\node3\node8
\node1\node4\node3\node9
\node1\node4\node3\node9\node10
I want to get all the paths containing leaf node. So ...
I have to query two different servers from a dynamically built query.
It basically gets data from one server, treats it, and inserts it into another server.
The only problem is I have to be sure it works for both situations:
If both the source and destination databases are on the same server, and if they're not.
I understand the conc...
How can I create a stored procedure that accepts a start and end date.(e.g April 1 - April 30
1.) Get the business days including Saturdays x (a value). +
2.) Get Holidays x (a value)
and return the total.
I'm new to this, I guess it would be a tsql function. hmm.
any help would be appreciated.
Thanks
...
Lets say i installed two named SQL Server 2008 instances e.g. A and B, will i have two services of each type e.g. two analysis service, two reporting service and so on, one service for A and the other for B? If yes, then it is known a service listens on a port number, how two same services going to listen on the port?
I hope this is cle...
Why did they never let us do this sort of thing:
Create Proc RunParameterisedSelect
@tableName varchar(100),
@columnName varchar(100),
@value varchar(100)
as
select * from @tableName
where @columnName = @value
You can use @value as a parameter, obviously, and you can achieve the whole thing with dynamic SQL, but creating i...
Hi,
i have two queries.
For each tuple of query1 i want to run query2. i dont want to use cursors. i tried several approaches using subqueries.
query1:
select
distinct
category,
Count(category) as CategoryCount
from
mytable
group by
category
query2:
select
top 3
Text,
Title,
Category
from
...
Hi
I am in process of building Dimension from EDW (source), wherein I need to pivot columns of source to load Dimension.
Currently most of the pivoting stuff am doing is by using T-SQL PIVOT which further get used in my SSIS package to merge with Dim table
This pivoting can also be achieved by SSIS PIVOT Transformation component.
In ...
Hi all
Here is my situation:
I use the SqlCommond to update some records in the SQL Server in a ASP.NET web site. Users can choose which records they want to update. Sometimes they may choose 40 or 60 records to update at a time.Is there any good way to do it? I do not want to do like it
foreach(string ID in List)
{
Update here
}
...
Hi,
I have a fairly weird 'bug' with a simple query, and I vaguely remember reading the reason for it somewhere a long time ago but would love someone to refresh my memory.
The table is a basic ID, Datetime table.
The query is:
select ID, Datetime from Table where Datetime <= '2010-03-31 23:59:59'
The problem is that the query resu...