Detect Empty Tables (probably Dead Easy)
Feb 19, 2001Hello,
does anyone know of a way that I can detect if a table is empty via a SQL Server job step?
Many thanks
DVNC
Hello,
does anyone know of a way that I can detect if a table is empty via a SQL Server job step?
Many thanks
DVNC
Hi there,
I'm a bit embarrassed about this question, because I'm sure that a lot of you would find it trivial, but I'm really not the best at T-SQL and especially not string handling.
I'm trying to generate a 'parent' value, by replacing characters in the 'child' field with '---'. It's a classic Chart of Accounts sort of problem, for feeding into a Parent/Child dimension in AS. It's a lot easier to understand if you look at this:
This is the set I have:
GLCode GLDescription
0.-.-.---- Balance S
0.0.-.---- Balance S.Balance Sheet
0.0.0.---- Balance S.Balance Sheet.Balance Sheet
0.0.0.5000 Balance S.Balance Sheet.Balance Sheet.Assets - Area1
0.0.0.5001 Balance S.Balance Sheet.Balance Sheet.Assets - Area2
0.0.0.5002 Balance S.Balance Sheet.Balance Sheet.Assets - Area3
This is the set I want
Ch GLCode Par GLCode GLDescription
0.-.-.---- -.-.-.---- Balance S
0.0.-.---- 0.-.-.---- Balance S.Balance Sheet
0.0.0.---- 0.0.-.---- Balance S.Balance Sheet.Balance Sheet
0.0.0.5000 0.0.0.---- Balance S.Balance Sheet.Balance Sheet.Assets - Area1
0.0.0.5001 0.0.0.---- Balance S.Balance Sheet.Balance Sheet.Assets - Area2
0.0.0.5002 0.0.0.---- Balance S.Balance Sheet.Balance Sheet.Assets - Area3
That is to say,
0.0.0.---- is the parent of 0.0.0.5001
0.0.-.---- is the parent of 0.0.0.----
0.-.-.---- is the parent of 0.0.-.----
So, what I really need to do is replace the last non '-' string with '-'. I've tried various combos of PATINDEX, CHARINDEX, REPLACE etc, but I'm really struggling. To make in more complicated, and of the strings between the . can be any length.
Any ideas?
Hi all,I have this code that I use for my Search function:SELECT DISTINCT [MUSIC_TITLE], [MUSIC_ORIGINAL_SINGER], [MUSIC_PERFORMER]FROM t_musicWHERE (@MUSIC_TITLE IS NULL OR [MUSIC_TITLE] LIKE '%' + @MUSIC_TITLE + '%') AND (@MUSIC_ARTIST IS NULL OR ([MUSIC_ORIGINAL_SINGER] LIKE '%' + @MUSIC_ARTIST + '%' OR [MUSIC_PERFORMER] LIKE '%' + @MUSIC_ARTIST + '%')) But right now if I don't enter anything in one of the textbox (2 have two, either of them can be left empty), the above Sql statement doesn't return anything since ADO.NET can't tell an empty textbox and treat it at null... So anyone please help me how to detect an empty textbox and set that to null for the above SQL statement to work. (It work in SQL Manager Studio, when I set one of the parameter = null.) I'm very new to ASP.NET stuffs, so if someone can help me to convert that function to code-behind and help me to call it from the .aspx, that would be even better as I don't want to put the code in my .aspx page... But I'm not quite there yet. Thank you all,Kenny.
View 19 Replies View RelatedHI,
Any help here is appreciated, I work in a large software company that has many small teams. I am faced with the issue of some of the other teams are changing the structure of tables and views and even SPs and functions without letting the rest know of these changes.
My question is, is there a way of tracking these changes through a job to alert everyone else in case this situation happens.
regards
I have two tables (tblRequest and tblDev) whose items have many-to-manyrelationships with each other. I have set things up like this(simplified):Table 1 fields: tblRequest.PrimaryKey tblRequest.Descriptionexample: 10 45 Elm11 63 Green12 123 Main Street13 23 PineTable 2 fields: tblDev.PrimaryKey tblDev.Descriptionexample: 20 Local. No issues21 City owned and main22 Out of county23 Not seen by officerThen Table 3 keeps track of the relationships between tables 1 and 2 bytracking the primary key of the linked items in tables 1 and 2.Table 3 fields: tblLink.RequestPrimaryKey tblLink.DevPrimaryKey10 2010 2111 2212 22Items from tables 1 and 2 may or may not have a relationship listed intable 3.So given an item in tblRequest:tblRequest.PrimaryKey tblRequest.Description12 123 Main StreetI need two queries...The first query would return ALL items from tblDev that are notassociated with this item in tblRequest - in this case 20, 21, 23.The second query would return ALL items from tblDev that ARE associatedwith this item in tblRequest - in this case 22.That's it. Thanks in advance
View 1 Replies View RelatedHi to all,
doe's anybody know how to print all the tables and schemes from the Microsoft SQL Management studio?
Thanks,
lior
I am sorry to post this simple question here but I could not find a right category thread to post this.
I am learning SQL Server 2005 and I have a very simple question.
I have already set up several tables and setup relations between them and have loaded data into tables.
How do I clear all the data in tables ?
Hi ,
I have two tables within a SQL database. The 1st table has an identified column and column which lists one of more email identifers for a second table,
e.g.
ID Email
-- ----------
1 AS1 AS11
2 AS2 AS3 AS4 AS5
3 AS6 AS7
The second table has a column which has an email identifier and another column which lists one email address for that particular identifier, e.g.
ID EmailAddress
--- ------------------
AS1 abcstu@emc.com
AS2 abcstu2@emc.com
AS3 abcstu3@emc.com
AS4 abcstu4@em.com
AS5 abcstu5@emc.com
AS6 abcstu6@emc.com
AS7 abcstu7@emc.com
AS11 abcstu8@emc.com
I need to create a stored procedure or function that:
1. Selects an Email from the first table, based on a valid ID,
2. Splits the Email field of the first table (using the space separator) so that there is an array of Emails and then,
3. Selects the relevant EmailAddress value from the second table, based on a valid Email stored in the array
Is there any way that this can be done directly within SQL Server using a stored procedure/function without having to use cursors?
Many Thanks,
probetatester@yahoo.com
Hi,
I've just creates a report with about 20 Tables. To my suprise, it almost runs as intended ;-)
But there is one flaw - Is there any way of hiding an empyt table?
I want to hide all tables that are not filled with data. But wich one is empty differs from the entered parameter.
So long
Sven
(Germany)
I want to return a list of user tables from a database where the rowcount is 0. This will be a 3 step process: (1) truncate all 'New%' tables, (2) load data via ODBC/DTS into 'New%' tables, (3) list all 'New%' tables with zero rows (i.e. those that didn't get loaded, as all tables in the ODBC data source contain data).
I've tried:
select left(s2.name,32) as TableName, max(s1.rows) as Records
from sysindexes s1
inner join sysobjects s2 on s1.id=s2.id
where type = 'U' and s2.name like 'New%'
group by s2.name
HAVING max(rows) = 0
ORDER BY TableName
but of course there are multiple rows in sysindexes and the routine does not reliably return the correct list; for example the data in sysobjects & sysindexes, without the max and group by, might look like:
TableNameRows
NewARTxn0
NewARTxn1214800
NewARTxn1214800
NewARTxn1214800
NewARTxn1214800
NewARTxn1214800
NewARTxn1214800
I was hoping to come up with a single T-SQL statement that I could use in an xp_sendmail situation to email me the results.
Thanks for the suggestions.
Al
I would like to empty out my 2k8 database (remove all the data in the tables only) And reloaded it with the data from production (2k5). I know I would have to dis-enable any constraints, triggers and remove all indexes before I can run a Truncate/Delete on all tables correct And then import the data via Wizard or script And lastly enable all the constraints & triggers, rebuild the indexes. Is this the only way to go about this? I don't want to do a backup & restore because the 2k5 doesn't have a 20% of the tables that are in 2k8. The 20% of those tables in 2k8 i'm not going to remove.
View 0 Replies View RelatedHello I have 16000 tables in a sql database and I need a sql query command to delete empty tables from that sql database please help.
F16 LÃ?GHTÃ?NÃ?NNNG
Hi all,
I have a database which gets its daily feed from a ftp file. Now is there any way i can figure out the empty tables in the databese which doesnot get any data on the feed.
Thanks in advance,
I'm running a master package executing 8 child packages.
Each package contains the same connection managers and each package is stored within the MSDB database.
The master package executes the packages stored in the MSDB using the 'execute package task'.
When running the master package from either MSDB or visual studio directly the odd thing happens that some tables will be filled, but after package execution I notice each table to be empty. There's no rollback 'procedure 'specified within the package and each package executes successfully because of error row handling. Anybody any hints how to solve this one?
Hello All,
When creating my database I have modeled some of the tables after the Adventureworks sample database.
There are some fields or entire tables in Adventureworks that I do not see an imediate use for, however; I would hate to ommit them to find out later they would have been benificial. (.eg territory table).
In general terms what would the impact be on size and performance of a database which contains tables or fields that do not contain data.
Thanks for your help!
:cool:
what should i do . if my database having deadlock?
anyone?
thanks
Sir,
This is top urgent Sir !
There are 2 tables for transaction. The header and tail tables. How do I insert records. if one is updated & another is not ? the sequence for tracking the records will fail. How do I deadlock the table for insert especially when I use stored procedures for 'Inserts'.
Sundar Raman S K
Hello !!!
I have 2 transactions, the first one has MANY updates to the table A and it finishes with a commit or rollback (ONLY AT THE END), the second one has only one insert into the table A that finishes with a commit or rollback, the problem is that the update process takes a long time to finish, and the insert process could be thrown during the first process, there's where I get everything locked cause the table A is locked and my java aplication gets stuck.
Note: When I execute each transaction independient I have no problems.
Is there any possibility to lock table A completly for the first transaction and release It for second one ??
Could you give me any suggestion of what to do step by step ?
Thanks !!!
Hi
could anyone pls tell me how to avoid deadlocks during as iam stuck up with this problem during large no of hits to server.
Iam a slow walker but i never walk back
It's been pretty quiet on here recently - no-one experiencing any corruption problems we haven't already given guidance on? Cool...
Paul Randal
Lead Program Manager, Microsoft SQL Server Storage Engine + SQL Express
(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.)
I have a Orders table, this has a Primary key on one Column
( OrderID )
We are using a Stored Proc to insert data into this table ( I am not
starting the Transaction in the stored Proc ) as its controlled by the front end written in C++.
when ever there is a update on this Orders table I move the record to the ordershistory table. ( I have a trigger in the CTOrders table
on INSERT and UPDATE )
The C++ App does an Async I/O. Offlate the App is experiencing a few dead locks during the day espicially at the market open and Close as this database is for the Trading System.
I need a few pointers as to start debugging this.
Thx
Trying to get SQL 2005 to report dead locks via email.
I performed the following
Execute Sp_configure ‘blocked process threshold’, 200
Then generated a deadlock
BEGIN TRAN
UPDATE CUSTOMER
SET CUSTOMER_NAME = 'F'
WHERE CUSTOMER_ID = '1'
WAITFOR TIME '17:52'
ROLLBACK TRAN
Then on another query ran this
SELECT CUSTOMER_NAME FROM CUSTOMER
In sp_who i see it blocked. and the select is waiting for the update.
But i do not get anything reported in logs for the dead lock.
I tried to set up an alert.
MSSQL$ASRCFHSQL2005:Locks
Number of Deadlocks/sec
Total
rises above 1
When doing the reconfigure is something supposed to be written to the logs..........
Trying to set up system so if any dead locks arise i am sent an email
Thanks
I have a SQL Server 2005 system that has been running for about 2 years. This morning nothing will connect. SQL Server Agent will not start. It gives me the message
"The request failed or the Service did not respond in a timely manner. Consult the event log or other applicable error logs."
The error log only states the SQL Server Agent cannot connect to server CANSPEC-TMMCSQLDEV and it is shutting down.
When i try to logon to SQL Server using Management Studio i get the following message:
"A connection was successfully established with the server, but then an error occured during the pre-logon handshake. Provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe. Microsoft SQL Server Error : 233"
The help for this error states that it could be caused by the fact that SQL Server does not allow remote connections. I have remote connections turned on.
Any ideas??
Microsoft products that are doing well tend to have very strong communities around them, and I am starting to get a bit disappointed with SQL-CLR. This forum seems fairly light, the links int he FAQ are broken, and the official SQL-CLR blog has no update since 2006..
Taking all of that into account I am forced to wonder, Is this a dead subject?
I am not trying to say that the people in this forum are doing something wrong, nor am i claiming that no one uses SQL-CLR (i am a user, thats why im here). But I did want to get the opinion of the group here of where they think this concept stands.
I think SQL-CLR can really be a good tool in the chest for various scenarios. I am for one using it to have a generic SQL-CLR Stored Procedure that can analyze small sets of data and move it into various buckets depending on validation rules built into the code. So far its working very well, but I admit it has not yet hit production so only time will tell. (Performance is always a concern of mine)
Regards,
Dmitry.
http://blog.lyalin.com
Hi There,
I was updating a Custome Error Log table in different Data Flow Task in a Package. Custom log table is being used to log the Redirect Rows which sent by a component if it has errors. So I am catching the error raised by componets and putting them all into one table. I thing this could be the cause for the following error. I am not sure Please help me out. What could be the cause of this error and how to prevent it?
SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft OLE DB Provider for SQL Server" Hresult: 0x80004005 Description: "Transaction (Process ID 71) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.".
Dear Friends,
Please help me in below unexpected error.
Server Details:
HP Proliant DL385 G1, 142*6 GB
AMD Opteron „¢ Processor 280, 2.40 GHz
4.00 GB RAM, DVD ROM
Win2K3 R2, SP1 64bit
SQL Server Details:
SQL Server 2000 Enterprise Edition 32bit
Service Pack4
Network Details:
Clients can access the server by Terminal Server and also by Direct Connectivity.
The connectivity is provided by RF network Provider.
Application Details:
Application was designed by Power Builder 6.5.
Error Details:
If I divide my clients connectivity to the server then it is divided into 3 types
TYPE A >> Users inside my LAN using a DNS server they give the server name in their Parameter file to connect to the Database Server.
TYPE B >> Users who are in WAN connect to the server by Terminal Servers for Data Input.
Terminal Servers are inside my LAN.
TYPE C >> Users who are in WAN connect to the Server by Direct Connection for Reports and Print Out they give the IP address of the Database server directly in their Parameter files.
After every 6 to 7 days the ERROR DB Processes Dead comes to the TYPE C.
The error Numbers are 100025 and 100005.
At the same time TYPE A AND TYPE B are not getting any errors.
For further diagnosis I have taken a client machine to Net Meeting and taken his desktop in control. I have connected the client machine to the database server by ISQL in command prompt.
From Backend I can see that the SQL server has allocated a SPID to the client machine. After I have executed
1>SELECT * FROM SYSDATABASES
2>GO
It will return me all data but it will not show me how many rows selected or EOF.
After some time it will give me the prompt (3>) but without EOF and after that if I give another query then it will give the below error
DB-Library: Attempt to initiate a new SQL Server Operation with results pending.
DB-Library: Unexpected EOF from SQL Server. General Network Error. Check Your Documentation.
Net-Library error 10054: ConnectionCheckForData (CheckForData())
DB-Library: DBPROCESSES is dead or not enabled.
DB-Library: DBPROCESSES is dead or not enabled.
DB-Library: DBPROCESSES is dead or not enabled.
DB-Library: DBPROCESSES is dead or not enabled.
At the same time if I give IP address of another server then it works and TYPE A and TYPE B don€™t get any problem.
To stop this error I have to restart the server after that for again seven days it works and again the same problem.
I cant find anything I have checked tempdb, cache size but it is normal no abnormal activities.
No virus Issues.
Please advice.
Regards,
James
Dear all,
I am build an application based on different WCF services which colect different type of data from an SQL database.
I can have up to 10 clients whcih could at a certain times collect the same data as a read or right operation.
I have run a test where I have only 2 clients, and I have been surprise to receive a nice error of dead lock process.
The error is as follow :
Transaction (Process ID 63) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction."
In the store procedure which I am suspected, not sure yet, I have been advise to use the
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
but no help
According to what I could notice in my application, I have one process which insert rows in this table, while clients read the same table..but I guess dead lock need to investigate in a more better way and handle it anyway...
I am not a databse administrator so I have no idea how to handle such situation.
Thnaks for your help
regards
serge
Please help me to remove deadlock. Server Error in '/' Application.
Transaction
(Process ID 69) was deadlocked on lock resources with another process
and has been chosen as the deadlock victim. Rerun the transaction.
Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException:
Transaction (Process ID 69) was deadlocked on lock resources with
another process and has been chosen as the deadlock victim. Rerun the
transaction.
Source Error:
Line 292: da.SelectCommand.Parameters.Add(HierCode3)Line 293: Dim ds As New DataSetLine 294: da.Fill(ds, "Employees")Line 295: Con.Close()Line 296: Dim dt As DataTable = ds.Tables("Employees")
Source File: C:InetpubwwwrootDTRVersion2.0Home.aspx.vb Line: 294
Stack Trace:
[SqlException (0x80131904): Transaction (Process ID 69) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857466 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +735078 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838 System.Data.SqlClient.SqlDataReader.HasMoreRows() +150 System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout) +214 System.Data.SqlClient.SqlDataReader.Read() +9 System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping) +156 System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue) +153 System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) +172 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +175 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +137 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83 _Default.LoadfromDB() in C:InetpubwwwrootDTRVersion2.0Home.aspx.vb:294 _Default.getData() in C:InetpubwwwrootDTRVersion2.0Home.aspx.vb:143 _Default.Page_Load(Object sender, EventArgs e) in C:InetpubwwwrootDTRVersion2.0Home.aspx.vb:30 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
HI,
i am updating one table, this transaction and another transaction
causing the Dead lock.
How i have to resolve a Dead lock issue.
--venu
hi, I ran a query on a test database and got this error , does anyone tell me whatdoes it mean and how can I fix it
thanks
Ali
This command did not return data, and it did not return any rows
DB-Library Process Dead - Connection Brokenh
I'm having a transactional replication which replicates data every 1min.... and i got a job which runs every 15mins and pulls the reports from source db which is being replicated.
Some times when the replication is pushing the data the same time the job is trying to generate reports and as the table is being locked at the time of replication the dead lock issue is rinsing and the job is getting failed.
Please some one help me in solving this issue.
Thanks
Hello,
Can anyone help me how to solve this problem ?
I had message "DBPROCESS is dead or not enabled" from my Server SQL v.4.2.1b.
I hope anyone want to help me.
Regards,
Susan
Hi All,
Would really like insights in determining how to fix the following problem.
( i did search the archives -- got nothing)
When I try to run query against the SQL server i get following message; Process 13 error "DB -library process dead", terminating connection.
Thanks a lot
Prasad