I have a Sql Server 2005 table with following data:
idHearing is the primary key (identity), idCase is a foreign key that may duplicate. StartDate and StartTime specify the date and time of the event - both fields are of DateTime type (for whatever reason these are separate fields). All StartDate data has a time of 12:00:00. All St...
Hello Experts,
I'm just a beginner in development field.Looking for SQL Server books. Please tell me which is good book to study from.
Any suggestion and pointer will be really helpful . thanks
...
Sorry for the poor question wording I wasn't sure how to describe this. I want to iterate through every row in a table and while doing so, extract a column, parse the varchar that is in it and depending on what it finds insert rows into another table. Something along the lines of this:
DECLARE @string varchar(max);
foreach row in (selec...
Suppose you have to build a DB tables that depicts states and their borders between each other. Let's say the States table would look like:
States: Name(PK), Size, etc...
What would be the appropriate way to define the relationships (borders) between states?
I came up with three alternatives -
Defining a Borders table with primary k...
How can I write this code in T-SQL?
var categories = new []{ "cat1", "another category", "one more" };
for (var i = 0; i<categories.count; i++)
{
insert into Categories (id, name)
values (i, categories[i])
}
Is it possible?
...
I'm trying to use an SQL insert statement to migrate rows from a table in one database to a table in a different database. The statement works until I add a unique index on the destination table and at that point I'm struggling to get the insert statement to be able to exclude the duplicates. Here's what I though should work:
INSERT INT...
Hi,
Is there a way to pass the value of combination variable to another variable?
I guess better of with a simple code that I wrote...
DECLARE @intFlag INT
DECLARE @taxdepn1 varchar(1) = 'A'
,@taxdepn2 varchar(1) = 'B'
,@taxdepn3 varchar(1) = 'C'
,@taxdepn4 varchar(1) = null --'D' `
DECLARE @xxx varchar(1000);
SET @i...
What is the difference between FOR and AFTER in trigger definition. Any benefits of using one vs another?
If I issue an update statement which updates 5 rows, does the trigger (with FOR UPDATE) fires 5 times? If it is so, is there any way to make trigger fire only once for the entire UPDATE statment (even though it updates multiple r...
Which one is better using condition in where statement or in join statement?
Can anyone please help?
...
Hi I had created a fulltext catalog search with FREETEXT below but I dont know what is the best way on how to integrate it into the store procedure that I made. Somebody told me that I should create an Index view for Fulltext Search, how can I do this and how can I integrate this to my SP query?
--Start Fulltext Search query
SELECT u.I...
Hi Everyone,
I'm using SQLServer2008 Express
I have a table and a script to convert the rows into columns with expected result as
PARENT_ID name01 name02 name03 name04
1 ABC DEF ABC2 DEF2
2 DEF3 null null null
However, I get the result as
PARENT_ID name01 name02 name03 ...
Hi all I have a sql query
SELECT FKid1, FKID2, a, b, c
from [source]
where FKID1 = 3
which returns the following data set so
(hope formatting holds)
FKID1 FKID2 A B C
3 40297 0 0 2
3 40297 0 100 1
3 40325 0 0 2
3 40325 0 0 3
3 40325 0 10 -1
...
I work at a college a change to policy is Students windows accounts are now disabled upon creation and are only enabled upon them passing a test. Don't ask
So I can easily modify my DSADD with -disabled yes
However I need to enable them when they pass the test. I obtain the test results from a sql server so is it possible to enable the...
Can I use expressions in Sql Server Reporting services to combine all of the values of a column within a group? I'm trying to accomplish what MySQL's group_concat function does, but in the report (not in the query).
Example. I want to make this data:
Group 1 Value
Test
A
B
Test 2
C
D
Look this t...
I'm trying to write this as part of stored procedure on SQL Server 2000. I keep getting a syntax error thrown on line starting Insert into OPENROWSET(.....
Help! I can't see the syntax error!
DECLARE @vDate Varchar(25)
DECLARE @vCommand nvarchar(1000)
DECLARE @fileName varchar(500)
SET @vDate = LEFT(DATENAME(month, DATEADD(m, -...
I am getting strange results from a query using XML EXPLICIT mode in T-SQL (SQL Server 2008).
Can someone explain what I am doing wrong?
Here is my example:
declare @parents table(id int, connection int, title nvarchar(255));
declare @children table(id int, connection int, title nvarchar(255));
insert into @parents(id, connection, ti...
Given the following data:
CardholderID Source DateTime
-------------- ---------------------------------------- -----------------------
3 2nd_Flr_Ramp_Out_Reader 2010-06-30 13:58:42.410
3 2nd_Flr_Ramp_In_Reader 2010-06-30 13:44:22.417
3 ...
Hi,
Can anyone explain me how many constraints at most can be set on any given column of a table in SQL Server.
...
Hi,
SELECT @s = ISNULL(@s + '. ' , '') + [Comments]
FROM [Customer]
RETURN @s
How can I catch Null or '', so that if its either It Won't append to the string and not add a '.'
Thanks
Jacob
...
Hi there, This actually applies to a prior question, TSQL 2008 USING LTRIM(RTRIM and Still Have Spaces
I am at the point of writing a very lengthy SELECT statement using OMG PONIES statement to remove NON NULL non visible characters
(WHEN PropStreetAddr is NOT NULL THEN
(SELECT LTRIM(RTRIM((REPLACE(PropStreetAddr,
...