Switching Database's And Retrieving Table, Etc Info

Jul 8, 2007

I have a query that gets the tables, columns, indexes, index_columns for all tables in a data base.

But, I need to be able to select any data base on the server
and then drill down into the tables, columns, etc.

I looked at sys.databases but can't see how to relate that to the
sys.tables to extend my query.

Is there a way?

I've looked at the information_schema area and catalog views
but I don't see a solution yet.

View 7 Replies


ADVERTISEMENT

Retrieving Indexes Info

Jun 19, 2006

Hi,

Is there any way to retrieve index information for a database through a SQL query?

I usually query out tables structure, et al using INFORMATION_SCHEMA. Is there anything like that for indexes?

Thanks,
Paul

View 8 Replies View Related

Storing And Retrieving Info In Non-English Languages

Sep 1, 2006

Hi,I am tasked with creating a site in two languages: English and Farsi (Persian), which is a right-to-left language.I am having problems with the Faris version when it comes to stroing and retrieving data. I can use Farsi fonts and type data into tables, but when I try to retrieve them they are displayed as ?????. I check the table and it says there were problems retriving data and asks to run the query again. When I click on "Execute SQL", the content of the fields that were in Farsi change to ?????.I am new to MS-SQL and would appreciate it if you could tell me how to set up non-English database.TIA.

View 16 Replies View Related

How To Insert All Info From A Table Of Database To Onther Table Of Other Database?

Mar 16, 2004

I have two database and both of them has the same table, i want to copy all info from this first table to the secornd table

For Example:
Database : DB_1, table is table_1
Database : DB_2, table is table_2

both table_1 and table_2 have the same struct

how can i insert all records from table_1 to table_2

thanks

View 4 Replies View Related

Error Message While Retrieving Table From Database

Dec 15, 2004

well i have got a form which displays some result from the databasse, it runs fi9 in webmatrix, but when i try to run it from my main page and when i click on that button which should displays the aspx page, it gives me this error:

############################################################

Server Error in '/' Application.
--------------------------------------------------------------------------------

Login failed for user 'MUFADDALASPNET'.
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: Login failed for user 'MUFADDALASPNET'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[SqlException: Login failed for user 'MUFADDALASPNET'.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +472
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +44
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +36
Microsoft.Matrix.Framework.Web.UI.SqlDataSourceControl.PopulateDataSet(DataSet dataSet, String listName) +494
Microsoft.Matrix.Framework.Web.UI.SqlDataSourceControl.GetDataSource(String listName) +51
Microsoft.Matrix.Framework.Web.UI.DataBoundControl.ResolveDataSource() +95
Microsoft.Matrix.Framework.Web.UI.DataBoundControl.DataBind() +59
Microsoft.Matrix.Framework.Web.UI.MxDataGrid.DataBind() +10
Microsoft.Matrix.Framework.Web.UI.MxDataGrid.OnPreRender(EventArgs e) +62
System.Web.UI.Control.PreRenderRecursiveInternal() +62
System.Web.UI.Control.PreRenderRecursiveInternal() +125
System.Web.UI.Control.PreRenderRecursiveInternal() +125
System.Web.UI.Page.ProcessRequestMain() +1489




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573


############################################################





i have kept no passwords in my mssql server 2000 database

can anyone help me out with this problem

View 2 Replies View Related

How To Access The Info Of A Table Created In Other Database

Aug 24, 2006

SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'tab_db1'The above query will give the information of the table 'tab_db1' if it is available in the current database (say db1) connected.How can i access the information of a table (say 'tab_db2') which is created under a different database say db2 from the current db connected say db1.I tried the above query with changing the table_name to 'db2..tab_db2'but went invain.sysobjects also dint work..Any help on this will be appreciated..regards,Sathya V

View 2 Replies View Related

Is There A System Table With Timestamp Info Or DTS Job Info?

May 7, 2007

I want to be able to see when records have been added to a table. The issue is we have a DTS job scheduled to run every night. The developer who wrote it password protected it and doesn't work here anymore. I want to add a step to this series of DTS jobs and want to run it just prior to his job. Is there a way to see when the records are being added or when this job is being run? Thanks again, you guys are the best.

ddave

View 3 Replies View Related

SQL 2012 :: Switching From One Database To Another Within The Same Script?

Jan 28, 2015

I would like to know how I can switch from one database to another within the same script. I have a script that reads the header information from a SQL BAK file and loads the information into a Test database. Once the information is in the temp table (Test database) I run the following script to get the database name.

This part works fine.

INSERT INTO @HeaderInfo EXEC('RESTORE HEADERONLY
FROM DISK = N''I:TESTdatabase.bak''
WITH NOUNLOAD')
DECLARE @databasename varchar(128);
SET @databasename = (SELECT DatabaseName FROM @HeaderInfo);

The problem is when I try to run the following script nothing happens. The new database is never selected and the script is still on the test database.

EXEC ('USE '+ @databasename)

The goal is switch to the new database (USE NewDatabase) so that the other part of my script (DBCC CHECKDB) can run. This script checks the integrity of the database and saves the results to a temp table.

What am I doing wrong?

View 2 Replies View Related

Multiple Tables - Loop Through Query Switching Table Name?

Mar 8, 2012

I would like to run the same query on multiple tables. So say I have a list of tables

@tableList = a|b|c|d

And then I have my query looping through the tables

for (@table in tableList)
{
update from @table
set = ''
}

Is there a simple way to do this in an mssql query, if so how do I get to loop through the query switching the table name?

View 4 Replies View Related

Transact SQL :: Check Constraint On Switching In Table Not Working?

Jul 7, 2015

I have a table which has been partitioned on BIGINT column.

Partitioned_Table (ID BIGINT, Name VARCHAR(10), Gender VARCHAR(2))

I have a left range partition function on ID column.

CREATE PARTITION FUNCTION Partition_Function ( BIGINT )
AS RANGE LEFT
FOR VALUES ( '20150601000', '20150602000', '20150603000' );

That means the first partition is ID  >= 20150601000 to ID < 20150602000.

 I have to switch in a table into an empty partition.

Switching_In_Table(ID BIGINT, Name VARCHAR(10), Gender VARCHAR(2))

Before the switch in, I am creating a CHECK constraint on Switching_In_Table CHECK(ID LIKE '20150625%') Can I use like clause in this scenario?

View 6 Replies View Related

Need Help Switching From MS Access Database To SQL Database

Sep 16, 2006

I recently created a form to MS access database web application and it worked fine on my local cpu.  When I published the same web app to my hosting server the program wouldn't work but I couldn't understand.  Well, after researching the matter I found out my hosting server doesn't allow ASP.NET applications that use the aspcompat page directive because of security trust levels.  So, I decided to switch to a SQL database but I can't even test the web application on my local cpu because I get this error "An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)".  So, once again I researched this error on the internet and found these two websites with incite to what is causing the error. http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277http://www.cryer.co.uk/brian/sqlserver/hresult_0x2%20npp_error_establishing_connection.htmI tried all the remedies suggested except for the cmd procedure in the second lind because I don't understand how to run that command in sqlcmd from start>run.  Anyway, I can't get my web application to work and I wanted to know if someone can assist me.  I use the following programs:MS Visual Web Developer 2005 Express EditionMS SQL Server Express 2005 Here is my code:sqlForm.aspx<%@ Page Language="VB" Debug="true"%><%@ Import Namespace="System.Data" %><%@ Import Namespace="System.Data.SqlClient" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim connContacts As SqlConnectionDim strInsert As StringDim cmdInsert As SqlCommandconnContacts = New SqlConnection("Server=MSSQL$SQLEXPRESS;database=contacts")strInsert = "Insert users ( name, email, comments ) Values ( @name, @email, @comments )"cmdInsert = New SqlCommand(strInsert, connContacts)cmdInsert.Parameters.AddWithValue("@name", txtName.Text)cmdInsert.Parameters.AddWithValue("@email", txtEmail.Text) cmdInsert.Parameters.AddWithValue("@comments", txtComments.Text)connContacts.Open()cmdInsert.ExecuteNonQuery() Response.Write("The form information was inserted successfully.") connContacts.Close() txtName.Text = ""txtEmail.Text = ""txtComments.Text = ""End Sub</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"><title>Untitled Page</title><style type="text/css">body {background-color:aqua}</style></head><body><form id="form1" runat="server"><div><asp:Label ID="Label1" runat="server" Text="Name:" Width="120px" ForeColor="#FFFFFF"></asp:Label><asp:TextBox ID="txtName" runat="server" Width="200px"></asp:TextBox><br /><asp:Label ID="Label2" runat="server" Text="Email:" Width="120px" ForeColor="#FFFFFF"></asp:Label><asp:TextBox ID="txtEmail" runat="server" Width="200px"></asp:TextBox><br /><asp:Label ID="Label3" runat="server" Text="Comments:" Width="120px" ForeColor="#FFFFFF"></asp:Label><asp:TextBox ID="txtComments" runat="server" TextMode="MultiLine" Width="200px"></asp:TextBox><br /><asp:Button ID="Button1" runat="server" Text="Submit" Width="110px" OnClick="Button1_Click" /></div></form></body></html>Please help! Note: I'm trying to test on my local cpu first with the intention of publishing to my hosting server. 

View 6 Replies View Related

Retrieving Data From SQL Server Table To Display On Button On Datagrid Table.

Oct 10, 2007

I have nine type of buttons,
EnrollAmtBTM
PlacAmtBTM and so on, I also have a SQL setver view V_Payment_Amount_List from here i need to display the data on the button
this is the select value to display when i choose the agency list and the amount corresponding to that agency_ID is displayed here the agency_ID is fetched from the SQL CONDITION
 THIS IS WHERE I GET FETCH AGENCY DATA WHEN SELECTED i.e SQL CONDITIONprotected void CollectAgencyInformation()
{
WebLibraryClass ConnectionFinanceDB;ConnectionFinanceDB = new WebLibraryClass();
string SQLCONDITION = "";string RUN_SQLCONDITION = "";
SessionValues ValueSelected = null;int CollectionCount = 0;if (Session[Session_UserSPersonalData] == null)
{ValueSelected = new SessionValues();
Session.Add(Session_UserSPersonalData, ValueSelected);
}
else
{
ValueSelected = (SessionValues)(Session[Session_UserSPersonalData]);
}ProcPaymBTM.Visible = false;PaymenLstBTN.Visible = false;
Dataviewlisting.ActiveViewIndex = 0;TreeNode SelectedNode = new TreeNode();
SelectedNode = AgencyTree.SelectedNode;
SelectedAgency = SelectedNode.Value.ToString();
Agencytxt.Text = SelectedAgency;
Agencytxt2.Text = SelectedAgency;
Agencytxt3.Text = SelectedAgency;DbDataReader CollectingDataSelected = null;
try
{CollectingDataSelected = ConnectionFinanceDB.CollectedFinaceData("SELECT DISTINCT AGENCY_ID FROM dbo.AIMS_AGENCY where Program = '" + SelectedAgency + "'");
}
catch
{
}DataTable TableSet = new DataTable();
TableSet.Load(CollectingDataSelected, LoadOption.OverwriteChanges);int IndexingValues = 0;foreach (DataRow DataCollectedRow in TableSet.Rows)
{if (IndexingValues == 0)
{SQLCONDITION = "where (Project_ID = '" + DataCollectedRow["AGENCY_ID"].ToString().Trim() + "'";
}
else
{SQLCONDITION = SQLCONDITION + " OR Project_ID = '" + DataCollectedRow["AGENCY_ID"].ToString().Trim() + "'";
}
IndexingValues += 1;
}SQLCONDITION = SQLCONDITION + ")";
ConnectionFinanceDB.DisconnectToDatabase();if (Dataviewlisting.ActiveViewIndex == 0)
{
Dataviewlisting.ActiveViewIndex += 1;
}
else
{
Dataviewlisting.ActiveViewIndex = 0;
}
SelectedAgency = SQLCONDITION;
ValueSelected.CONDITION = SelectedAgency;
 
 
???? this is where i use to get count where in other buttons and are displayed.... but i changed the query to display only the Payment_Amount_Budgeted respective to the agency selected. from the viewRUN_SQLCONDITION = "SELECT Payment_Amount_Budgeted FROM dbo.V_Payment_Amount_List " + SQLCONDITION;
try
{
CollectionCount = ConnectionFinanceDB.CollectedFinaceDataCount(RUN_SQLCONDITION);
EnrollAmtBTM.Text = CollectionCount.ToString();
}
catch
{
}////this is my CollectedFinaceDataCount-- where fuction counts the records in the above select statement if i use for eg.
"SELECT Count(Placement_Retention_ID) FROM dbo.V_Retention_6_Month_Finance_Payment_List"
here is the functionpublic int CollectedFinaceDataCount(String SQLStatement)
{int DataCollection;
DataCollection = 0;
try
{
SQLCommandExe = FinanceConnection.CreateCommand();
SQLCommandExe.CommandType = CommandType.Text;
SQLCommandExe.CommandText = SQLStatement;
ConnectToDatabase();DataCollection = (int) SQLCommandExe.ExecuteScalar();
DisconnectToDatabase();
}catch (Exception ex)
{Console.WriteLine("Exception Occurred :{0},{1}",
ex.Message, ex.StackTrace.ToString());
}
 return DataCollection;
}
 
 
So here mu requirement request is to display only the value fronm the view i have against the agency selected
Please help ASAP
Thanks
Santosh

View 8 Replies View Related

Delete Rows In One Table By Referencing Another Table Info

Sep 16, 2004

I have one table that has unique id's associated with each row of information. I want to delete rows of information in one table that have a unique ID that references information in another table.

Here is a basic breakdown of what I am trying to do:

Table1 (the table where the rows need to be deleted from)
Column_x (Holds the id that is unique to the various rows of data - User ID)

Table2 (Holds the user information & has the associated ID)
Column_z (holds the User ID)

I tried this on a test set of tables and could not get it to work. What I am trying to do is skip all rows of Table1 that have ID's present in Table2, and delete the rows of ID's that are not present in Table2.

Code:


SELECT Column_z
FROM dbo.Table2
DELETE FROM dbo.Table1
WHERE Column_z <> Column_x


This did not seem to do what I needed, it did not delete any rows at all.

I wanted it to delete all rows in Table1 that did not have a reference to a user ID that matched any ID's in Column_z of Table2

Then I tried another scenerio that I also needed to do:

Code:


SELECT Column_z, Column_a
FROM dbo.Table2
DELETE FROM dbo.Table1
WHERE Column_z = Column_x AND Column_a='0'



'0' being the user id is inactive so I wanted to delete rows in Table1 and remove all references to users that were in an inactive status in Table2.

Neither one of the Queries wanted to work for me in the Query Analyzer when I ran them. It just said (0) rows affected.

Any ideas on what I am doing wrong here?

View 3 Replies View Related

SQL - Retrieving Same Table Twice

Jan 5, 2006

Hi,

I have a giant SQL query that retrieves a bunch of information from a couple of tables for use on a page, and I would like some help on constructing the SQL to get exactly what I have in mind. I have a table - called scContacts - that contains a list of contacts with detailed information. The contacts in the table are regular sales contacts, sales reps, and sales managers. Another table - called scCompany - contains a list of companies with detailed information.

For each company, we have a certain sales manager (or user) pertaining to that company as well as potentially a certain rep. The problem is that the contact tied to the company, the sales manager tied to the company, and the rep tied to the company all come from the same table. Here is the base SQL code I've used to get everything but the sales rep's name and sales manager's name:

----- SQL CODE -----
SELECT DISTINCT
scContacts.ID,
scContacts.inheritCoAddr,
scContacts.fName,
scContacts.lName,
scContacts.contact,
scContacts.billToAddress1,
scContacts.billToAddress2,
scContacts.billToState,
scContacts.billToZip,
scContacts.billToCity,
scContacts.billToCounty,
scContacts.billToCountry,

scCompany.ID AS companyID,
scCompany.companyName,
scCompany.companyURL,
scCompany.billToAddress1 AS companyAddress1,
scCompany.billToAddress2 AS companyAddress2,
scCompany.billToCity AS companyCity,
scCompany.billToState AS companyState,
scCompany.billToZip AS companyZip,
scCompany.billToCounty AS companyCounty,
scCompany.billToCountry AS companyCountry,
scCompany.businessType,
scCompany.phoneExt,
scCompany.phoneNum,
scCompany.faxNum,
scCompany.minEmployees,
scCompany.maxEmployees,
scCompany.actionTypeMAX,
scCompany.actionDateMAX,
scCompany.actionTimeMAX,
scCompany.statusID,
scCompany.userID,
scCompany.repID

FROM
scCompany,
scContacts

INNER JOIN
scStatus ON
scStatus.ID = scCompany.statusID

WHERE
scgroupContacts.contactID = [insert cookie value]
AND
scgroups.ID = [insert cookie value]
AND
scCompany.ID = scContacts.companyID
AND
scCompany.groupID = scgroups.ID
----- END SQL CODE -----

As indicated right now, this SQL code will retrieve all of the contact and company information for a certain contact ID which comes from a cookie value (inserted in ASP). I want to get the [fName] and [lName] fields from scContacts table where the scContacts.ID = scCompany.userID, and I also want those same fields from scContacts table again where the scContacts.ID = scCompany.repID. It would be simplest and most efficient if I could do this all at once (and I'm sure it's possible). How would I change the SQL to bring in that information from the same table two more times, tying their ID's to ID's in the company table?

thanks,
mellamokb

View 3 Replies View Related

Retrieving A Given Id From More Than One Table ???

Jun 5, 2006

bobby writes "I have a Table from which i get the ID of customers(Customers are people who have written an online exam).The date of completion of the exams are stored in the corresponding table with the name of the exam.There are more than one exams and the names of the exams are stored in an other table.Now my question is how to get the date of cpletion with the given Id from the first table?"

View 2 Replies View Related

Not Sure How To Get Info From Other Table

Aug 31, 2005

I am having problems with my store procedure displaying my last column name which is "DISPLAY_CATEGORY_DESC". I am trying to display the description from another table. But in order to get to the description I have to go through 2 tables. The tables look like something like this.

First TableTABLE_CATEGORY

PRIMARY_KEY = DIR_CATEGORY_ID = 5000

Column Name
DIR_CATEGORY_LVL_ID1 = 100
DIR_CATEGORY_LVL_ID2 = 200
DIR_CATEGORY_LVL_ID3 = 300

Second TableTABLE_CATEGORY_DESCRIPTION
PRIMARY KEY DIR_CATEGORY_LVL_ID1 = 100

Column Name
DESCRIPTION = "Car Model Company"

This is my DISPLAY_CATEGORY_DESC

Not sure how to get to this description. Thanks for your help.


select cwebs.SESSION_ID, webs.ENTERED_DATE, cwebs.DIR_CATEGORY_ID, DISPLAY_CATEGORY_DESC

FROM di_webclickstats cwebs
left join di_websessions webs on cwebs.session_id = webs.session_id
where cwebs.DIR_CATEGORY_ID <> 0 and webs.ENTERED_DATE between @startDate and @endDate+1

View 3 Replies View Related

Retrieving PDF From MS Sql Database Using C#

Sep 24, 2007

I am now retrieving the PDF from the database and I am getting an error: 
Error 1 'GetImages.GetImage(int)': not all code paths return a value
I have:
int imageid = Convert.ToInt32(Request.QueryString["ACTUAL_IMAGE_PDF"]);
And...
 private SqlDataReader GetImage(int imageid)
{
Sql Statement...
}
Could someone help please??

View 3 Replies View Related

Database Info

Jan 15, 2008

Hi,

I need to list in Word doc all the databases, tables and sp under a server. Is there a quick method of doing that?

Thanks

Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much.

View 3 Replies View Related

Retrieving Data From SQL Table

Feb 5, 2008

 this is a simple problem but it's just driving me mad as it's not reading from my dB. basically, I've have reviews stored in my dB and want to display them in a textbox by clicking on a button called btnReviews. I think the problem might be that there is too much text stored per row of the table (as it is a review), but I have the datatype set as text in sql. here's the simple un-errorred code I have behind the button. any ideas where I went wrong. i've a feeling it's something small but it's just taken too long to figure out.protected void btnReviews_Click(object sender, EventArgs e)    {        String strConn = ConfigurationManager.ConnectionStrings["conLocalDatabase"].ConnectionString;        SqlConnection dbConnection = new SqlConnection(strConn);        SqlCommand dbCommand = new SqlCommand("Select [ReviewC] From [Review])", dbConnection);          dbCommand.Parameters.AddWithValue("Review", txtReviewView.Text);        try        {            dbConnection.Open();            dbCommand.ExecuteNonQuery();        }        catch (SqlException ex)        {            Console.WriteLine(ex.ToString());        }        finally        {            if (dbConnection != null)            {                dbConnection.Close();            }        }            }

View 6 Replies View Related

Retrieving Data From More Than One Table

Apr 28, 2008

Hi
  I ve a datagrid . And Two Database table in sqlServer2005.  The name of the tables are 'Property' and 'userid'.
  My datagrid wants to retrive all records from Property table and one record from userid table. The Property table contains Propertycode, lastdate , departmentname.   
  The userid table contains so many record along with 'id'  record  which my datagrid wants to retrieve.
pl tel me how 2 write code for that? 

View 1 Replies View Related

Retrieving PK To Insert Into Another Table

Mar 7, 2006

The query below should be inserting unique records in the PropertyItem table which only has propertyitem, propertyid, and itemid columns, all of which are PK's in other tables. I'm not doing the insert correctly b/c it's inserting 72 records instead of 24. I really just want to automatically insert the values once I've inserted in the other tables but I'm not sure how. Maybe On Update Cascade?


--PROPERTYITEM
INSERT INTO [USCONDEX_Production].[dbo].[propertyItem]( [propertyId], [ItemId])
SELECT Property.propertyId, ITEM.ItemID
FROM ITEM RIGHT OUTER JOIN
miamiherald ON ITEM.StartDate = miamiherald.FirstInsertDate AND ITEM.Price = miamiherald.PropertyPrice AND ITEM.Classified = convert(int,miamiherald.AdNumber) LEFT OUTER JOIN
Property ON property.adprintid = miamiherald.adprintid
WHERE validAD=1

View 1 Replies View Related

Table Usage Info

Jan 14, 2002

Is there a utility or function or 3rd party product that will show information about tables and other objects such as:

Last change date
Last used date
Where Used
more .....

I'm from an AS/400 environment and found it VERY useful to be able to access that kind of information to clean-up, monitor & manage the systems.

Any Ideas ?

View 1 Replies View Related

How To Select Table Info?

Apr 7, 2008

Hi

Can someone write a query for me that would return names of tables that would slelect all tables of particular database and show if table has set primary key and if it has then if key has Identity Specification set to true?

something like:

SELECT
TABLE_NAME
,HAS_PRIMARY_KEY
,KEY_HAS_IDENTITY_SPECIFICATION
FROM
...this is where you come in
ORDER BY
TABLE_NAME

View 6 Replies View Related

Same Table - Subset Of Info

Oct 25, 2007

I'm beating my head up against a wall here. I have one very LARGE table called op_hist.

CREATE TABLE [dbo].[op_hist] (
[op_trnbr] [int] NOT NULL ,
[op_type] [varchar] (80) ,
[op_date] [smalldatetime] NULL ,
[op_act_setup] [decimal](38, 10) NULL ,
[op_act_run] [decimal](38, 10) NULL ,
[op_qty_comp] [decimal](38, 10) NULL ,
[op_wkctr] [varchar] (80) ,
[op_part] [varchar] (30)

)

I need to be able to sum items grouped by op_wkctr and op_part and op_date. Here's my latest version which of course does not work.

SELECT op_wkctr, pcs, hrs.b
FROM
dbo.op_hist
INNER JOIN
(
SELECT op_part, SUM(op_qty_comp) as pcs
FROM dbo.op_hist
where op_type='BACKFLSH'
group by op_hist.op_part

UNION ALL

SELECT op_part, SUM(op_act_setup + op_act_run) as b
FROM dbo.op_hist
where op_type='LABOR'
group by op_hist.op_part
) AS hrs
ON op_hist.op_part = hrs.op_part
where (op_wkctr = 'P-P36' or op_wkctr = 'P-P38' or op_wkctr='P39') and op_date ='10/22/07'

Help me oby one - you're my only hope.

Sincerely,
Frustrated!

View 4 Replies View Related

Move Info From A Table In One Db To Another

Mar 25, 2008

Hello All.

I just made some huge changes to a database on the development computer. However, I want to transfer all of the information from the Employees table in the old DB to the new DB (no changes made on that table).

Can anyone point me in the right direction?

View 4 Replies View Related

How Would You... (binary Info In A Table)

Sep 15, 2007

I have run into a challenge that I'm not sure how to best solve. I'dappreciate any opinions or input.I am working with a third party database. They are storing some datathat I need to use in a binary field. I've got the code to parse thebinary and reconstruct what I need. Unfortunately, there might bemultiple "entries" stored in a single binary field. a certain byte,let's just say the first, will always be the count of "entries" inthis particular SQL entry.An example:then entry might be:0x01000012341234where 12341234 is the data entry that I will parse.Another possible entry is:0x03000012341234567856789ABC9ABCThe first byte indicates that there are three data values I want toparse out:12341234567856789ABC9ABCThe portions of the binary I need are always the same length and theremay be from 1 to ~100 of them. (usually 1 if it matters.)The big question:How could a SQL query return an entry for each of the "entries" in thebinary field? For the second example I would want three entries in myresults, each row returning a different section of the binary data.For the first, only one row. I'll be querying the set and expecting toget back more results than the number of entries in the set.I haven't really tried much with this yet, (other than some mentalcalisthenics were I fell down onto the mat pretty hard), so just somedirection on where to begin would be helpful.(Yes, I understand that the difficulty is that this data shouldn't bestored this way, but there is not much I can do about that.)Thanks...James FraserJoin Bytes!

View 4 Replies View Related

How To Get Table Info From RID Deadlock ?

May 7, 2007

Hi There



I am trying to troubleshoot deadlock issues.

The dead lock is with a RID.



Now from various links i have established that you have to use DBCC PAGE() with relevant info to get more information, i get back a object and index id, m_objid.



However i dont know how to get the tablename form here, msdn simply says that it is an allocation id not and actual table id, so how can i from here get to table information?



All i am trying to figure out is which table is affected fromt he RID dealock, but that does not seem to be a simple process.



Thanx

View 5 Replies View Related

Table Size Info

Apr 24, 2008

Does TSQL (2005) offer a way to retrieve a given table's total size (data size vs index size)? Would like to be able to get at this info using TSQL (not management studio).

thanks

View 3 Replies View Related

How To Select Table Info?

Apr 7, 2008

Hi

Can someone write a query for me that would return names of tables that would slelect all tables of particular database and show if table has set primary key and if it has then if key has Identity Specification set to true?

something like:

SELECT

TABLE_NAME
,HAS_PRIMARY_KEY
,KEY_HAS_IDENTITY_SPECIFICATION
FROM

...this is where you come in
ORDER BY

TABLE_NAME

View 3 Replies View Related

Retrieving Image From SQL Database

Jul 3, 2007

Ok, again, I'm reasonably new to this. I've been trying to display an image stored in SQL in a ASP.NET page. Pretty simple stuff I would have thought. I've read countless examples of how to do this online, and many of them use the same method of displaying the image, but none seem to work for me. The problem seems to lie in the following line of code:
Dim imageData As Byte() = CByte(command.ExecuteScalar())Which always returns the error: Value of type 'Byte' cannot be converted to '1-dimensional array of Byte'.Here's the rest of my code, hope someone can help. It's doing my head in!
Imports System.Data.SqlClient
Imports System.Data
Imports System.Drawing
Imports System.IOPartial Class _ProfileEditor
Inherits System.Web.UI.PageProtected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Get the UserID of the currently logged on user Dim NTUserID As String = HttpContext.Current.User.Identity.Name.ToString
Session("UserID") = NTUserID
Dim Photo As Image = NothingDim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString)
Dim command As SqlCommand = connection.CreateCommand()
command.CommandText = "SELECT Photograph, ImageType FROM Users WHERE UserID = @UserID"command.Parameters.AddWithValue("@UserID", NTUserID)
connection.Open()Dim imageData As Byte() = CByte(command.ExecuteScalar())Dim memStream As New MemoryStream(Buffer)
Photo = Image.FromStream(memStream)
End Sub
End Class

View 4 Replies View Related

Retrieving Image From Database

Sep 22, 2007

Dear Friends,
 I have read many solution over the net, but since I am unable to utilize anyone according to my needs I am seeking help from you people.
I have a table imagedata in sql server 2005 having fields name and imageperson. Name is string and imageperson is Image field. I have successfully stored name of the person and his image in database.
I have populated the dataset from codebehind and bind it to the repeater.
By writing  <%# DataBinder.Eval(Container.DataItem, "name")%>I am a able to retrieve the name of the person. But when I pass photodata as
<%#photogen((DataBinder.Eval(Container.DataItem, "imageperson")))%>
where photogen is function in code behind having structure
public void photogen(byte[] dataretrieved)
{
Response.BinaryWrite(datarerieved) 
}
 But it is giving error at <%#photogen((DataBinder.Eval(Container.DataItem, "imageperson")))%>
The best overloaded method match for '_Default.photogen(byte[])' has some invalid arguments
AND
Cannot convert object to byte[].
Can anyone please provide me working solution with code for aspx page and code behind.
Thanks and regards

View 1 Replies View Related

Retrieving A Value From A SQL Database In Code Behind

Nov 29, 2007

VWD 2005 Express.  I need to retrieve a value from a SQL database from the code behind a page and assign it to a variable.  In Microsoft Access I can do this using the DLookup function.  What I need to do is get the data that results from the following query into a variable:
SELECT [SystemUserId] FROM [SystemUser] WHERE ([Username] = @Username)
The name of the data source is SqlDataSource2
Also, in Access I can create a recordset from a query and then process through the recordset.  Can that be done in VB code in VWD 2005 Express?

View 16 Replies View Related

Retrieving Database DDl Commands

Mar 25, 2008

 Hi everyoneI created a database graphically in VS2005.Now I want the text version of those DDL(create) commands. Question is where and how are those commands stored in SqlServer  I have the management studio too. Any ideas?? 

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved