
Puiu
Avatar/Signature-
Posts
90 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Puiu
-
Concurrency violation while row exists
Puiu replied to ChoKamir's topic in Database / XML / Reporting
Did you try to put a dataset.AcceptChanges after the update? -
I thought of something, but i don't know whether it will help you or not! So I assume you have a table named FlightPlan or something with the following columns: Date, ArrivalAm, DepartureAm, ArrivalPM, DeparturePM (btw, why do you have arrivalAm and ArrivalPM? ) Now you cannot you'll have to take them on at a time! (you will need like 4 stored procedures) an the code for the stored proc that would return the earliest time for arrivalAM would be something like: Create Proc EarlyArrivalAM as create table #TempTbl1 ( Date smalldatetime, ArrivalAM smalldatetime, DepartureAm smalldatetime, ArrivalPm smalldatetime, DeparturePm smalldatetime ) create table #TempTbl2 ( Date smalldatetime, ArrivalAM smalldatetime, DepartureAm smalldatetime, ArrivalPm smalldatetime, DeparturePm smalldatetime ) insert into #tempTbl1 (Date) select distinct Date from FlightPlan insert into #tempTbl2 select * from FlightPlan order by ArrivalAm update t1 set t1.ArrivalAM = t2.ArrivalAm, t1.DepartureAm = t2.DepartureAM, t1.ArrivalPm = t2.ArrivalPM, t1.DeparturePM = t2.DeparturePm from #TempTbl1 t1, #TempTbl2 t2 where t1.Date = t2.Date select * from #TempTbl1 this should return the earliest ArrivalAm time for each distinct date try it and see if it returns what you need if there is a simpler solution for this pls post it..sometimes i complicate things witout wanting it :)
-
The last time i had the same problem i used a temporary table. I created a temporary table with 2 columns(just like in your case) Create #TempTbl ( MyDate datetime, MyValue varchar(20) ) Than i made an insert like insert into #TempTbl (MyDate) select distinct MyDate from MyTable After that i did an update of the #TempTbl: update t set t.MyValue = m.MyValue from #TempTbl t, MyTable m where t.MyDate = m.MyDate and then a simple Select * from #TempTbl Hope it helps
-
Is there another way for importing data from an excel file other than using ad hoc queries (opendatasource)? I want to import the data using sql server 2005 express. Thanks
-
I have 2 computers, A and B. On computer A I have installed sqlserver 2005 and I have enabled Ad Hoc queries. On computer B I have an excel file, MyExcel.xls. On comp B I have installed only SQL Server Management Studio and it can access the databases on computer A On computer B I�m trying to select the data from that excel file(witch I remind you is on computer B) using the following query: select * from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0', 'Data Source="\\ComputerB\Share\MyExcel.xls";user id=myUser;password=myPassword; Extended properties=Excel 8.0')...Sheet1$ When I parse this query I got the message: �Ad hoc access to OLE DB provider 'Microsoft.Jet.OLEDB.4.0' has been denied. You must access this provider through a linked server.� I red somewhere to add the DissAllowAdHocAccess in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL1\Providers\Microsoft.Jet.Oledb.4.0 I did that and now I get the error: OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned message "Cannot start your application. The workgroup information file is missing or opened exclusively by another user.". Msg 7399, Level 16, State 1, Line 1 The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" reported an error. Authentication failed. Msg 7303, Level 16, State 1, Line 1 Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)". In conclusion: How can I use ad hoc queries from remote computers accessing a SQL Server? Thanks
-
Maybe you could post the query...so i get an ideea of what it is about..
-
How to update datagrid by commandbuilder?
Puiu replied to goharulislam's topic in Database / XML / Reporting
You cannot update multiple tables using a commandbuilder. Your query must not contain a join for the commandbuilder to work! The code is something like this: Dim cb As New SqlCommandBuilder(DataAdapter) DataAdapter.Update(DataSet) dataset.AcceptChanges you must supply a valid dataadapter that fills a dataset using a query that selects data only from one table and it is not using a join to retrieve the data. Maybe you could show us some code and maybe someone will figure out what your problem is Cheers -
I think you could also have something like: declare @AdjustWidth int, @AdjustThickness int, @TotalWidth int select @AdjustWidth = Width - 1 from Orders select @AdjustThickness = Thickness + 4 from Orders select @TotalWidth = 2*@AdjustWidth + @AdjustThickness select Height, Width, Thickness, @AdjustWidth, @AdjustThickness, @TotalWidth, 8*@TotalWidth as TotalTimes8 from Orders
-
If you are using a select query, than you should use a "Select distinct..." syntax
-
If you say the tables aren't related i don't think there will be any problem. You could use Connection pooling also, so that you don't have to open the same connection more than once. A problem could have occured if you'd want to access the same table at same time. For that you would have used deadlock pripority: http://msdn2.microsoft.com/en-us/library/ms186736.aspx
-
Subtracting one queried value from another
Puiu replied to robojam's topic in Database / XML / Reporting
Maybe you could use a temporary table with 2 columns, one for each value of AS_REP and then substract them. I don't know how to create temp tables in oracle, but it should't be difficult. You'll have 2 queries like: insert into ##TempTbl (AS_REP1) select AS_REP FROM CARD_TABLE WHERE CDATE <= '01-Dec-2001' AND CDATE >= '01-Nov-2001' AND TNAME = 'TRSTXN' and the second: insert into ##TempTbl (AS_REP2) select AS_REP FROM CARD_TABLE WHERE CDATE <= '01-Dec-2001' AND CDATE >= '01-Nov-2001' AND TNAME = 'TRS554N' select @Result = AS_REP1 - AS_REP2 from ##TempTbl -
Selecting between SQL Server 2005 dates + vb.net code.
Puiu replied to mike55's topic in Database / XML / Reporting
Did you try adding a .ToString to the Convert.todatetime(fromDate), like: Convert.todatetime(fromDate).ToString ? Oups, my bad, erase that! i didn't read it carefully -
You could use dynamic SQL here: declare @SQL as varchar(400) select @SQL='' select @SQL = @SQL + 'select Top ' + replace(cast(@ParamTop as varchar(10)),'''','''''') + ' * from customers' exec (@SQL) Some explaining: @ParamTop will be declared by you as a parameter for the stored procedure, type int if the id is the primary key of your table (and i think it is) than you should not use the order by id, because the results are automatically ordered by the id (Ex: select top 10 from customers) hope it helps
-
I did as Nerseus said and i still got the same error. the owner set for my database was the windows administrator and that seemed to be the problem. I switched the owner to sa, i reconnected and it worked! However if i try to set the owner back to Computer\Administrator it gives me an error: The proposed new database owner PUIUALEX\Administrator is mapped as user PUIUALEX\Administrator in this database. Parameter name: PUIUALEX\Administrator My guess: I don't have a login associated with this user....but i'm not sure :)
-
I could give you a possible solution using sql: you could create a stored proc. In that stored proc you could create a temporary table where you would store the records obtained with your select query. After that you do an update on the temp table: update ##Temptbl set column1 = '' where column1 is null And you return the temp table: select * from ##Temptbl PS: Welcome
-
Sqltransaction Class vs StoredProcedure Transaction
Puiu replied to sureshcd10's topic in Database / XML / Reporting
Is this true for the stored procedures that have parameters also ? -
Sqltransaction Class vs StoredProcedure Transaction
Puiu replied to sureshcd10's topic in Database / XML / Reporting
I knew there was no pre-compilation for the stored procs. They are compiled when when they are used, just like any other query. The difference is that the execution (query) plan for the stored proc is easyer to retrieve from the cache (or at least this is what i know) -
The syntax for the query should be "Alter table trans add biscuit <type of value here>" You shouldn't worry about the order of the columns because you can arrange them when you make the select clause: "Select cake, pastry, biscuit, totalquan from trans" If you want to drop a column: "Alter table trans drop column biscuit" That should do it
-
Hello, I have a table with 3 foreign keys in it. My question was: should I create a single covering index on the 3 FK or I should create 3 separate indexes ? Thanks
-
breakpoints on sprocs in sql server 2005?
Puiu replied to fguihen's topic in Database / XML / Reporting
In SQLExpress 2005 i don't think there is..i haven't seen it. But it should be on other SQL Server 2005 editions. I know that in SQL Server 2000 you could debug a stored proc -
If your data source is a dataset then do something like this: dataset.clear and after that fill the dataset again If you do not use a dataset, then simply reconnect to the mdb file again
-
Default Values using Stored Procedure
Puiu replied to rmatthew's topic in Database / XML / Reporting
I think you could create a stored proc that would contain the code from the first stored proc where you get your value(s) and after that the insert statement... -
Could we see your insert code ?..maybe there realy is an error in it.
-
I want to store a 13 digits number in a table in a database and i was curios what would be the best data type to do this? Varchar or Bigint ? I don't need to calculate anything with these numbers, just to store them using the lowest disk space
-
Cags: It' s a custom TabControl that can hide the tabs...however there are over 20 tabs so i was wondering if it will not need to much RAM...