all groups > sql server programming > march 2007 > threads for friday march 2
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 29 30 31
How to check the records have been locked when you select the reco
Posted by marxi at 3/2/2007 9:46:05 PM
Now some records have been locked by one user and the others select these
records at meanwhile. So the others how to know these records have been
locked?
The locked method I used like this:
Begin tran
select * from table with (repeatableread)
--commands
commit tran
--
marxi... more >>
Unique Combinations Query (from the other end)
Posted by stjulian at 3/2/2007 5:36:25 PM
I have a list of values from an online survey.
Customer Item
---------- -----
1 A
1 C
2 A
2 B
3 A
3 C
4 A
And would like to return a list based on varying criteria, for exam... more >>
ERROR MESSAGE
Posted by Ken at 3/2/2007 5:27:56 PM
Anyone have a idea about what is meant by below?
/****************************************/
Cannot roll back ken. No transaction or savepoint of that name was found.
Transaction count after EXECUTE indicates that a COMMIT or ROLLBACK
TRANSACTION statement is missing. Previous count = 65, curr... more >>
Newbie question about triggers/store procedures
Posted by Willo at 3/2/2007 4:01:10 PM
Hi;
im really new with programming SQL server, i just create my first Trigger
(not an easy task, but it works)...
now i need to create a trigger or store procedure (im not really sure), to
compare the sum of two fields and check for a value on another table,
before allow any insertion, ... more >>
Server roles in MSSQL 2005
Posted by Jodie at 3/2/2007 3:25:24 PM
Hi All,
In MSSQL 2005 to view the server roles of the user I did the following:
Enterprise Manager->Click on server->Secuirity->Login then click
on user and then properties to bring up the "SQL Server Properties" for the
user
and in this window I can click on Server Roles to view the server ... more >>
select into
Posted by Jeff Ericson at 3/2/2007 2:46:46 PM
Select into will recreate the base table. Select *, '' as newcol, null as
newcol2 from sometable will create the original table with two new columns.
newcol will be varchar(lengthofstring) not null and newcol2 will be an int
null. Is there anyway to control, I'd like to create a varchar(25)... more >>
How can I get error message and set as value
Posted by Ken at 3/2/2007 2:19:58 PM
How can I catch and set the error message.
for example I got system error message like
"
Msg 208, Level 16, State 6, Procedure sp_RunDBSqlScripts, Line 124
Invalid object name 'dbo.sp_RunDBSqlScripts_sqldev5.
"
set like
set @errormessage = " " -- message from above.
... more >>
get error without execute query
Posted by Ken at 3/2/2007 1:52:38 PM
Is there any way to find if certain query make error or not without execute?
because I plan to write record into table about the query such as "insert,
delete, update". However I don't want to effect to the tables which the
queries executed into.
I used the rollback function to make execut... more >>
Don't see what you're looking for? Search DevelopmentNow.com.
count three fields
Posted by JFB at 3/2/2007 1:40:02 PM
Hi All,
Can I get a count base on some condition from three fields at the same time?
Tks
JFB
--- one at the time ----
select count(field1) as expr1
from addresses
where field1= 'Lima'
--looking for
select count(field1) as count1, count(field2) as count2, count(field3) as
count3
from ... more >>
Convert Number to SmallDateTime
Posted by Curious Joe at 3/2/2007 1:08:13 PM
I have a drop of data from a client that stores their date fields as a
numeric. The format is yymmdd. The problem is that they do not have
strict date rules for this field and there can be "garbage" contained
within it. I want to convert/cast this data to a SmallDateTime field
but it chokes o... more >>
Exec across instances?
Posted by G.Waleed Kavalec at 3/2/2007 1:05:45 PM
I know how to use EXEC across servers: EXEC
myserver.mydatabase.dbo.myproc
But if I am on instance myserver AA and I need to execute something on
instance myserver BB?
EXEC myserver\BB.mydatabase.dbo.myproc
doesn't pass syntax
Anyone!
... more >>
Combine IN & LIKE
Posted by JayKon at 3/2/2007 11:08:52 AM
Is there a way to combine the functionality of IN & LIKE?
I would like to write:
SELECT *
FROM Table
WHERE Col IN ('%pat1%', '%pat2%', etc...)... more >>
Coding a backup script
Posted by JayKon at 3/2/2007 11:01:11 AM
I'm rewriting SQLGuys's backup script as a detailed excersize and would like
your thoughts on Logical Log backup placement when a full backup is being
preformed.
Under light insert/update/delete conditions, this doesn't matter. However,
under extreem conditions, it might.
When the progra... more >>
batch insert into a Huge table performance problems
Posted by Mike Kansky at 3/2/2007 10:55:00 AM
We have a table (TableB) which we use to archive records accumulated for the
day from (TableA).
All live applications are using TableA (1000 queries a minute)
When we archive the data from TableA to TableB we use this:
Insert into TableB select * from TablaA with (nolock) where
Create... more >>
reuse a calculated field name for further calculation
Posted by Xavier at 3/2/2007 10:52:12 AM
Hi,
is it possible to reuse a calculated fieldname (in the example sum1)?
example:
select (f1+f2+........fn) as sum1, (sum1*1000) as myvalue from my table
thanks
... more >>
Passing Date From Access to Stored Procedure
Posted by Tom LeBold at 3/2/2007 9:55:08 AM
What is the best way to pass a date from a Microsoft Access form to an SQL
Server Stored Procedure?
I'm using an ADO command object to pass the date in the text box to the
parameter
in the stored procedure. Passing a date in the YYYY-MM-DD format returns
more records then passing MM/DD/YYYY.... more >>
Could not attach the database because the files are readonly
Posted by Jodie at 3/2/2007 9:40:44 AM
Hi All,
I have been trying to attach the database but the error message come
back is "Could not attach the database, the files are readonly"
Have you have this problem before and how to solve it.
Thanks in advance,
JP... more >>
calculated fields
Posted by Xavier at 3/2/2007 9:20:02 AM
Hello,
i want to get an overview information over one select command that displays
me an information like:
From 1000 questios there are 500 resolved and 350 escalated and 250 open
Detailinformation:Table structure
country varchar(2)
questionId(int)
questionstate(varchar(50)
exampl... more >>
Bulk DELETE Performance
Posted by Competitive Dad at 3/2/2007 8:45:10 AM
I have a database table that has data constantly written to it.
There is a need to have a daily job that purges the data from the previous
day, but this could be a considerable amount of data, possibly hundreds of
thousands of rows or more.
I am worried that just doing a DELETE FROM <TABLE... more >>
DateTime datatype shows 2 days in the future
Posted by bmhicks at 3/2/2007 8:03:25 AM
The problem that I have seen is when executing the following statement on SQL
7, SQL 2005 and SQL 2005 Express, appears to be that SQL is adding 2 days to
a DateTime datatype value when put into a database through the SQL Insert
Statement. Going into a MSAccess database works fine. Does
... more >>
SQL Query to determine time start/end within a time range
Posted by Sammy at 3/2/2007 7:30:00 AM
From multiple records in a table, for a datetime field I am trying to get the
start/stop time for each range of times that doesn't have a gap of 15 minutes
or more.
Example Output desired from the example records below
Start: 05:57
End: 05:57
Start: 07:09
End: 07:15
Start: 09:06
... more >>
T_SQL on S!QL Server 2005
Posted by RickSean at 3/2/2007 7:26:41 AM
I have a number of table in a database and all the tables are named as
following format:
Table1
Table2
Table3
Table1x
Table2x
Table3x
etc.
I need a script that will:
1. verify if Table1 exists and then verify if Table1x exists; if yes then
delete Table1 and then rename Table1x to Tab... more >>
Months in a range
Posted by glbdev NO[at]SPAM gmail.com at 3/2/2007 6:59:12 AM
Hi.
Can anyone explain how to parse out the months within a date range?
For example, if I have a start date of '1/1/2006' and an end date of
'5/30/2006'. I need to parse out each month (1,2,3,4,5) and run
seperate queries in the stored procedure based upon each of those
months. The start ... more >>
Execute a SPROC from a vbscript
Posted by Leo Demarce at 3/2/2007 6:56:03 AM
Is there a vbscript / syntax to execute a sproc? I know how to create the
exec command in a DTS and schedule it to run, but if I want to have a macro
do it so that a user can manually invoke the macro what would that be?
... more >>
SQL Server 2000 and SQL 2005 client
Posted by jack at 3/2/2007 6:49:36 AM
May be this may sound silly for some of you but.
In my office the live server is SQL Server 2000. even client
Workstation (My PC) has sql 2000 client.
I want to work in SQL 2005 which my manager had approved for.. I have
windows XP installed in my workstation.
If I install SQL 2005 cli... more >>
Verify in a select if a file exists in a folder
Posted by Rui Oliveira at 3/2/2007 6:49:15 AM
Is possible verify in a select if a file exist in a folder?
I have a table that have a column FILE_NAME that is the file name.
I what select all lines in table that the FILE_NAME do not exist in a folder.
Is possible doing this in a select?
Thanks,
Rui
... more >>
Service packs
Posted by Sandy at 3/2/2007 6:30:00 AM
Hello -
Is it necessary to install SP1 before installing SP2 for Sql Server 2005, or
does SP2 contain all the bug fixes from SP1?
--
Sandy... more >>
ARGH!! ROUNDING!! Can't get rid of trailing zeros
Posted by Rico at 3/2/2007 6:11:09 AM
Hello,
I'm not sure if this is an SQL issue or an Access issue. I have an Access
2002 FE and I'm using a passthrough query to retrieve some information from
SQL server 2000. I am rounding in the SQL View to two decimal places, but
the passthrough is giving me numbers like 14.450000. I've... more >>
how to avoid duplicate result
Posted by junior at 3/2/2007 4:08:56 AM
Hello,
I have the following query,
SELECT GroupInfo.GroupID, GroupInfo.GroupName
FROM GroupInfo INNER Join DeviceGroup
ON(DeviceGroup.GroupID=Groupinfo.GroupID)
INNER Join Deviceinfo ON
(Deviceinfo.SerialNumber=DeviceGroup.SerialNumber )
It's out put is as follow:
Group ID ... more >>
Complex counting, joining and grouping
Posted by Patrick at 3/2/2007 3:34:03 AM
I have a sales stats table and I want to do some counting and grouping by
source and cluster (join required).
The 2 tables and sample data are as follows:
CREATE TABLE
dbo.stat (id_source varchar(10) not null,
id_period int not null,
id_dept varchar(10) not null,
ind_Domestic char(1... more >>
How to check if a value is GUID ?
Posted by Sagar at 3/2/2007 1:07:38 AM
I have a table T, one of the columns is tColumn varchar(8000) After
the table is populated, some field values in tColumn contain GUID
values SELECT * from T In my SELECT I want to filter out all the rows
which have a GUID values (uniqueidentifier) in tColumn. How can I do
it ? Is there funct... more >>
Comparing rows different tables and perform operation SQL Server 2
Posted by Pradeep at 3/2/2007 1:06:00 AM
Hello,
I need a suggestion regarding one of the scenario that i have currently
programmed for. It is as follows:
There are two tables. We need to check if a row in table1 is also present in
table2. If present, we need to update the value in table2 else insert it into
table2.
In a lega... more >>
Weird Tigger Behaviour
Posted by Path Finder at 3/2/2007 12:09:03 AM
I have a trigger
Create Trigger TTT On Table1 For Update As
Set
Declare @Active1 Bit, @Active2 Bit, @Val int
Select @Active1=Active From Deleted
Select @Active2=Active, @Val=Val From Inserted
If @Active1<>@Active2
Beging
Insert Into Table2(Field1, Field2) Select @Val, @ctive1
End
... more >>
Disable all contraints on all tables
Posted by dw at 3/2/2007 12:00:00 AM
Hi. Is there a way to disable all constraints on all user tables in a 2005
database via a SQL command? Also, is there a way to turn them back on?
Thanks.
... more >>
slipstream sp2?
Posted by Smokey Grindel at 3/2/2007 12:00:00 AM
Is it possible to slipstream SP2 of SQL Server 2005? I know SP1 didnt like
it, but did they finally fix it for SP2? and if so how do you do it? Thanks!
... more >>
pronounce varchar
Posted by Mark at 3/2/2007 12:00:00 AM
I have it in my head that varchar is correctly pronounced as var-"car".
However, I'm now surrounded by people who say var-"char". It's knocking my
confidence on the topic down to zero.
Which is it? Thanks!
-Humbled by Pronunciation in the Midwest
... more >>
How to concatenating from rows into string with delimited character(,)?
Posted by ABC at 3/2/2007 12:00:00 AM
Tripplecount with "math"
Posted by Lasse Edsvik at 3/2/2007 12:00:00 AM
Hello
I have a slight problem, I need to count 3 things and then do some math in a
single select. Not sure how to get it done properly without needing
subqueries. Hope it this testcode makes sense.
TIA
/Lasse
DDL:
CREATE TABLE #Tmp (
A char(1) NOT NULL,
B char(1) NOT NULL
)
G... more >>
Virtual listbox problem (classic VB solution preferred)
Posted by Martin Nemzow at 3/2/2007 12:00:00 AM
I want to load a "page" of 100 items at a time from a sql table with 1M rows
into a listbox. Ant good way to define the recordset with the first 100
records, next 100 records, and so forth so memory usage is optimized for
this?
Thanks
... more >>
|