all groups > sql server programming > february 2007 > threads for monday february 19
Filter by Day: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
problem with insert in two tables
Posted by michel at 2/19/2007 11:38:07 PM
Hi,
i have to insert values into two tables in one transaction.
The first table (base table) has a primary key (type 'int') which is
incremented automatically with each insert.
The second table (detail table) contains a field (type 'int') which must get
the value of the primarty key of the ... more >>
JOIN Problem - Avoid retrieving unnecessary fields
Posted by Patrick at 2/19/2007 11:08:20 PM
Hello,
My DB has a table "resources" with a relationship one-to-many to a table
"attributes". When I want to select all resources with their attributes
(filtered by some criteria in the resources table), I have two possibility.
1) I could select the records in the resources table (SELECT * FRO... more >>
Multiple select for different Rows
Posted by shiju at 2/19/2007 10:37:09 PM
RecordStatusID RecordStatusName
1 Success
2 Failure
I have to assign recordstatusid to variables for success and failure.
select @i = RecordStatusID from Recordstatus where RecordStatusName =
'S... more >>
SQL 2005 confidence?
Posted by Keith G Hicks at 2/19/2007 9:48:52 PM
I'm just getting done with version 1 of a long term project that was planned
for SQL 2k/MSDE (which one used by a customer depends on sevearl factors).
We've hesitated to move to 05 because from what I understand sql express has
more restrictions than msde. But I've noticed that the prices of SQ... more >>
Access Database query to MSSQL
Posted by MarkusJNZ NO[at]SPAM gmail.com at 2/19/2007 9:48:40 PM
Hi, I am moving over a query from MSAccess to MSSQL 2000 not 2005
unfortunately!
I have never really used Access a whole lot and have come up against
this query and really do not know where to start!
==================
TRANSFORM Count(TMPRESULTS.RESULT) AS CountOfRESULT
SELECT MGMTAREAS.MGMT_A... more >>
TSQL to obtain model info
Posted by Hassan at 2/19/2007 8:37:31 PM
What TSQL can I use to find the server model such as Dell Poweredge 6400 or
HP DL 385,etc.
I see that info in msinfo32, but can I just extract that one piece of info
using TSQL as I need to run it on many servers ? Is there some OLE object to
extract it and if so, how do I write the TSQL fo... more >>
SP2 for SQL Server 2005 is out
Posted by kb at 2/19/2007 8:06:33 PM
Microsoft SQL Server 2005 Service Pack 2
http://www.microsoft.com/downloads/details.aspx?FamilyId=d07219b2-1e23-49c8-8f0c-63fa18f26d3a
kb
http://kbupdate.info/
... more >>
Catch and dump result from nested SP's
Posted by René_Jensen at 2/19/2007 6:26:20 PM
Hello
At work we have some stored procedures which are nested..
sp1
sp2
and i'm creating sp1
sp1 ends with a select * from xxxxx
sp2 has a exec sp1 but not a insert into
sp2 ends with a select * from yyyy
I want to make sp3 end with select * from zzzzz
and all the "user"... more >>
Don't see what you're looking for? Search DevelopmentNow.com.
Truncate Tranaction Log
Posted by qjlee at 2/19/2007 6:08:05 PM
I am running SQL 2000. The transcation log is growing overly huge, over 16G.
Can you tell me how to truncate it?
Thanks,... more >>
Must declare scalar variable...
Posted by ana9 at 2/19/2007 5:37:40 PM
I have a query
SELECT *
FROM ....
WHERE (DATEADD(dd, 0, @date) = CONVERT(varchar(10), SR_Service.Date_Entered,
101))
ERROR:
Query execution failed for data set 'CurrentYear'
Must declare the scalar variable @date.
I use this same WHERE statement in other datasets within the same re... more >>
Begin Try/Catch Question/Problem
Posted by Amos Soma at 2/19/2007 5:26:21 PM
I am executing the T-SQL statement shown below in Management Studio (SQL
Server 2005). When I execute this, an error should occur because a clustered
index already exists on the table. What I don't understand is why I am
seeing the error in M.S. because I've wrapped this in a Begin Try / Begin... more >>
Why not to have many to many relationships
Posted by Hassan at 2/19/2007 4:47:15 PM
Why do we not have many to many relationships and instead build an
intermediary table ? Like to know why..
... more >>
Moved SQL system DBs and Master failed
Posted by Paul at 2/19/2007 4:34:03 PM
I followed the procedure outlined in
http://support.microsoft.com/default.aspx?scid=KB;EN-US;q224071&ID=KB;EN-US;q224071
and all went well up to Item 7. of 'Moving the master database' - that is
the line that tells you to restart Sql server. My SQL server will not
restart - it shows (Conne... more >>
Data Model for Application Inventory
Posted by Hassan at 2/19/2007 4:33:17 PM
Can someone help me provide a logical E-R model of the different entities
with relationship for collecting Application Inventory ?
The goal is to collect all the Applications along with dependencies.
On the top of my head, I can think of a Server/Hardware Table, an
ApplicationName Table th... more >>
Create Table MySQL / SQL
Posted by Zoë Braven-Giles at 2/19/2007 4:19:48 PM
Hi
Working with SQL Server 2005
I am trying to create a table with the following code
create table department
(dept_id smallint unsigned not null auto_increment,
name varchar(20) not null,
constraint pk_department primary key (dept_id)
)
but keep coming up with an error. I suspect th... more >>
Table Joins
Posted by Joe at 2/19/2007 2:29:57 PM
Is the following statement performing a Left Outer Join?
SELECT *
FROM table1 JOIN table2 ON table1.brid = table2.brid
... more >>
Read flat text file into a single row column? Bulk insert?
Posted by jobs at 2/19/2007 2:19:17 PM
I have a flat text ascii file with about 30 lines I'd like to read in
and store in a single row column. I'm trying Bulk insert with no field
and row terminators, but it is storing it in multiple rows.
Is Bulk insert the way to go? if so, how? and even if possible, how
will sql store my carria... more >>
Grouping by Date only
Posted by tshad at 2/19/2007 2:07:55 PM
I need to display my records grouped by Date only and not by time. I tried
a couple of things including:
SELECT count(*),Date = CONVERT(char(10), DatePosted, 103)
FROM Applicant
GROUP BY year(DatePosted),month(DatePosted),Day(DatePosted),DatePosted
But this still groups by date and time. ... more >>
SQL Mobile Connection Problem
Posted by R Gouws at 2/19/2007 1:37:25 PM
Hi, hope someone can help!!!
I am programming with VS2005 with SQL Mobile Database. I've created a SQL
mobile database and I can see it in my project. (MyTest1.sdf). I have the
following code that should create a connection to the database:
Imports System.Data.SqlServerCe
Imports System.C... more >>
what is this replace doing?
Posted by jobs at 2/19/2007 1:18:20 PM
Can somebody tell me what this replace line is doing? changing | , <
and > the front of the line??
select @FTPServer = replace(replace(replace(@FTPServer, '|',
'^|'),'<','^<'),'>','^>')
Also, is there any way to enter a carriage return when entering data
thorough the Open Table interface?
... more >>
sqlcmd in silent mode
Posted by John at 2/19/2007 12:29:55 PM
Is it possible to run sqlcmd in silent, or quiet mode where the console
window does not appear?
I am setting up an automatic backup system using calls to sqlcmd -Q with
the Windows Task Scheduler. The transaction log backups, especially,
will likely be run as users are working on the applic... more >>
DTC unable to begin
Posted by Darin at 2/19/2007 12:09:42 PM
I have a network w/ Windows 2003 server and 2 XP Pro SP2 laptops. One
laptop I can run the DTC with no errors (updates both the server and the
local laptop).
On the other laptop I get:
The operation could not be performed because the OLE DB proviers
'SQLOLEDB' was unable to begin a distribu... more >>
Time Zone Conversion
Posted by dbach at 2/19/2007 12:08:18 PM
Does SQL Server 2005 have some way to convert time from a column from GMT to
EST?
Our ERP system (BAAN) records all transactions in GMT, but our reports
should reflect EST. ... more >>
SQL coding
Posted by seouldar at 2/19/2007 11:15:02 AM
I'm doing this assignment for school and don't know what to do. All he wants
is the correct sql code for the follow:"we have too many kicking tees in
inventory and need to plan our ordering a little better. How many Kicking
Tees (ProductID: 17) did the customers buy each month last year? List... more >>
A complicated Query
Posted by Hadidi at 2/19/2007 9:53:28 AM
I've 3 tables :
1- Orders (Order_ID , Seller_ID , .....)
2- Sellers (Seller_ID, Name , ........)
3- Order_Pricing (Order_ID , Total_Price , ......... )
& The desired Query is :
List top 5 Orders per Seller (the top total_price)
Thanks
... more >>
Temp Tables
Posted by wnfisba at 2/19/2007 9:36:12 AM
Trying to undrestand Temp Tables here.
I thought Temp Tables were prefixed with a generic thread ID that identified
it to your session when you're signing on via SQL Query Analyzer.
In the past, I have forgotten to delete my #Temp Tables when I was done with
them. Are they dynamically dele... more >>
IF statement
Posted by peddie at 2/19/2007 8:19:36 AM
Hi
My business scenario is that I want to create a view that read the
data from 2 tables, depending on customer type. Say if the customer
type is 1, I want to retrieve address information from table A, if the
customer type is 2, I want to retrieve address information from table
B. I think I can... more >>
How SQL server sorts non-alphanumeric characters
Posted by Sandeep at 2/19/2007 7:43:00 AM
Hi all,
I am getting different results for the string data comparison provided by
Order By clause of SQL provider and the comparison provided by CRT
wcscmp/wcsicmp APIs.
For example,
I have two rows in nvarchar column with data as below.
Row1 : AB
Row2 : {AB
If we sort this column in a... more >>
Cannot resolve collation conflict for equal to operation.
Posted by bassman6000 NO[at]SPAM yahoo.co.uk at 2/19/2007 7:00:55 AM
I am currently moving various SQL objects from an old server to a new
server, the idea is to have a tidy up along the way since there is a
great deal of redundant views and procedures on the old system. I
have set up the new server exactly the same a the old server and have
been moving object a... more >>
Modified date in SQL 2005?
Posted by nomad at 2/19/2007 6:58:04 AM
Hi,
I want to be able to tell when a stored procedure or view was
modified. Is there anyway I can find this out in SQL 2005?
Appreciate the help
Damon
... more >>
Is there a difference in speed or locking between the folowwing delete operations?
Posted by Arian at 2/19/2007 6:45:36 AM
delete A
from myTable A (nolock)
where field = 'value'
delete
from myTable
where field = 'value'
... more >>
How to analyze disk queues?
Posted by DC at 2/19/2007 6:42:23 AM
Hi,
I am experiencing increasing disk queues on one drive (which stores
quiet a number of data files but not the indexes or trans. logs). I
can use performance analyzer to check which stored proc is causing a
lot of IO total, but I could not find out what would acutally cause
the queues. Is t... more >>
Maintaining a "shadow" table
Posted by DC at 2/19/2007 6:18:03 AM
Hi,
the data model of my application is centered around one table
("items") with about 1 mio. rows, which receives very frequent updates
plus there are a lot of selects happening on the table, too. Due to
locking (although I use nolock everywhere) a select that joins in 5000
rows of this tabl... more >>
SQL 2000 DST - [WP]
Posted by WILDPACKET at 2/19/2007 6:06:00 AM
I host my DB for Blackberry on SQL 2000 and I am not at all an SQL guy.
I am following KB931815 to see if my SQL is affected by DST.
How can I check if I am running the Notification Services 2.0 with/without
SP1?
The article tells me to Stop event provider, notification services gener... more >>
Insert data from Excel to SQL Server
Posted by MIB at 2/19/2007 6:00:12 AM
I Want to insert data from Excel to SQL server, what it is the best way to do
it.
I can't use SSIS (DTS) beause we are using Excel just to display data.
How to avoid concurency to data ?
Thanks... more >>
Missing rows and ID's skipped
Posted by ste.goddard NO[at]SPAM gmail.com at 2/19/2007 5:17:03 AM
Hi All,
I have a very strange intermittent problem with MSSQL 2000. Im having
a problem inserting data into a table. Occasionally data fails to
insert in to the table, yet the id is skipped on the next working
insert.
eg.
Insert - id =34
Insert - id = 35 Insert fails,no row can be found... more >>
how to set the foreign key in a child table into NULL?
Posted by Hercules Dev. at 2/19/2007 5:05:59 AM
Simple question but seems there is no answer to it at all!
I have a table T1, and there is another table T2 where T2 has a
foreign key on T1 (which allow NULL value), I want when I delete a row
from T1 to set the foreign key in table T2 to NULL, I can't use the
After Delete trigger on T1 cuz t... more >>
Using POWER
Posted by Alan Z. Scharf at 2/19/2007 5:00:42 AM
Hi,
I appear to be getting a different degree of precision in Query Analyzer,
depending on whether I square a number by straight multiplication vs. using
POWER.
1. SELECT ( .0814 * .0814) = .00662596
2. SELECT POWER(.0814, 2) = .0066
3. SELECT POWER(.08140, 2) = .00663... more >>
SQL Server Logon failure - after i restart the comp
Posted by Gopal at 2/19/2007 3:47:24 AM
Hello All,
I have installed SQL Server 2000 on the my comp to try few things. However,
what is happening is that when i restart the comp, it fails to logon.
SQL service manager/database every things fails with message that Failed to
start due to logon failure.
During installation i have... more >>
Newbie- Select ID with multiple entries,
Posted by Charlotte Howard at 2/19/2007 3:37:24 AM
Hi, I'm trying to retrieve data that will show where a person has joined a
pension fund, left it, and then rejoined. Also, I will need to find people
still active in the fund (i.e. they have a null date of exit)
From the small results field below, I will need to recieve entries for ID
37.4... more >>
Convert Varchar to Datetime Greater than 24h
Posted by Jean-Nicolas BERGER at 2/19/2007 3:30:08 AM
Hello,
I'd like to import a varchar( ) into a Datetime format.
This varchar( ) describes a duration that might be greater than 24h.
Could someone help me to create generic conversion syntax?
Thx.
JN.
select convert(datetime, '23:59') --> OK
select convert(datetime, '23:00') + convert(dateti... more >>
Slow runing query
Posted by Kayda at 2/19/2007 2:50:16 AM
Hi:
I have this simple query, that updates dates with a time zone offset:
UPDATE MainTable
SET NewTime_EST = DATEADD(hh,b.EST_Offset,OldTime) FROM
MainTable a INNER JOIN EST_OffsetTable b
ON a.Site = b.Site AND DATEDIFF(d,OldTime,b.Date) = 0
(the "Site" indicates one a few cities-and it ... more >>
Database Upgrade Test Toolkit
Posted by Ginny at 2/19/2007 1:26:17 AM
Hi,
From where can I download Database Upgrade Test Toolkit?
Ginny
... more >>
need help with output query
Posted by Ricky at 2/19/2007 12:28:34 AM
Hi
My doubt is related to an output that i only can do it by using a temporary
table and i didn't wanted to use that. So like i
said before here i am to ask for a little hand/help on this subject.
The above query represents the data i want to extract from the table
So when appears two nam... more >>
Primary key is doubled
Posted by simonZ at 2/19/2007 12:00:00 AM
I have table with primary key and index on columns:
ID(varchar(12)),ID_POST(int) and RCO(char(3)).
.....
CONSTRAINT [myConstraint] PRIMARY KEY NONCLUSTERED
(
[ID] ASC,
[ID_POST] ASC,
[RCO] ASC
) ON [PRIMARY]
But I have records with the same values in this columns.
How is that possi... more >>
Select Query works, Update won't
Posted by Lara at 2/19/2007 12:00:00 AM
This Query works perfectly, what I need is an update Query which updates
the, MaqrkDetails.Mark Column, in case it is null
SELECT Mark = dbo.ExtractMark(XmlDoc_Mark)
,SumMark= dbo.ExtractMark(XmlDoc_Add)
FROM Candidates c
INNER JOIN MarkDetails MD ON c.ID = MD.ID
INNER JOIN Address a... more >>
shrinking log file
Posted by Roy Goldhammer at 2/19/2007 12:00:00 AM
Hello there.
I asked this question before and the problem hasn't been solved.
Here is brief: I have database with 2.9 gb size of data and 1.4gb size of
log.
I have database maintenance plan that at 00:00am backup the data of the
database
and on 00:30 backup the log file.
both of the... more >>
PIVOT operator for variable number of transformations
Posted by mik at 2/19/2007 12:00:00 AM
Hi, i'm trying to port a pivot query from access to sqlserver.
I'm trying this query:
SELECT IDMerce, [1] AS [Department-1], [2] AS [Department-2], [3] AS
[Department-3], [4] AS [Department-4]
FROM (SELECT IDMerce, Pezzi, IDMagazzino
FROM Dispo... more >>
|