Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Friday, March 30, 2012

need help connecting to sql sever

Hi

I am able to connect to an sql server from my server explorer. Can't seem to connect
to an sql server from my code.

this is what i am doing

String strConnection = "server=FRANK;database=Northwind;integrated security=true;";
SqlConnection objConnection = new SqlConnection(strConnection);
objConnection.Open
objConnection.Close();

error Login Failure for user FRANK

I know that my server name is FRANK because thats what it says on my Sql Service manager.

And i use that same server name when i connect from my Server Explorer(using Visual Studio.NET) and then i get a listing of the the Databases that are associated with my SQL Server.

I have no problems coonecting to an Access dataBase using OLedbConnectionI'm not sure if "server" is the same as "Data Source", but try using "Data Source" instead:

String strConnection = "Data Source=FRANK;database=Northwind;integrated security=true";sql

Need Help Coalescing

Hi,
Below is the code I am struggling with. I want to return only those
"item_id(s)" that pertain to each member. The current results are
giving me every "item_id" for every member.
What am I doing wrong.
Thanks!!!
declare @.Indicatorgroup varchar(8000)
select
@.Indicatorgroup = coalesce(@.Indicatorgroup + ',','') + cast(item_id as
varchar)
from #temp_BLAH
group by Member, item_id
select +@.Indicatorgroup, Member
from #temp_BLAH
group by Member
So the results now are like this:
A,B,C,D,E....Z Smith, Ben
A,B,C,D,E....Z Jones, Dave
But Ben only has A, C, and D.
So I'd like the results to be like:
A,C,D Smith,Ben
A,J,Q Jones,DaveHi
The safe way to do this is to use a cursor if using SQL 2000 see
http://tinyurl.com/yat5xr
John
"Dubs" wrote:

> Hi,
> Below is the code I am struggling with. I want to return only those
> "item_id(s)" that pertain to each member. The current results are
> giving me every "item_id" for every member.
> What am I doing wrong.
> Thanks!!!
> declare @.Indicatorgroup varchar(8000)
> select
> @.Indicatorgroup = coalesce(@.Indicatorgroup + ',','') + cast(item_id as
> varchar)
> from #temp_BLAH
> group by Member, item_id
> select +@.Indicatorgroup, Member
> from #temp_BLAH
> group by Member
> So the results now are like this:
> A,B,C,D,E....Z Smith, Ben
> A,B,C,D,E....Z Jones, Dave
> But Ben only has A, C, and D.
> So I'd like the results to be like:
> A,C,D Smith,Ben
> A,J,Q Jones,Dave
>sql

Need Help Coalescing

Hi,
Below is the code I am struggling with. I want to return only those
"item_id(s)" that pertain to each member. The current results are
giving me every "item_id" for every member.
What am I doing wrong.
Thanks!!!
declare @.Indicatorgroup varchar(8000)
select
@.Indicatorgroup = coalesce(@.Indicatorgroup + ',','') + cast(item_id as
varchar)
from #temp_BLAH
group by Member, item_id
select +@.Indicatorgroup, Member
from #temp_BLAH
group by Member
So the results now are like this:
A,B,C,D,E....Z Smith, Ben
A,B,C,D,E....Z Jones, Dave
But Ben only has A, C, and D.
So I'd like the results to be like:
A,C,D Smith,Ben
A,J,Q Jones,Dave
Hi
The safe way to do this is to use a cursor if using SQL 2000 see
http://tinyurl.com/yat5xr
John
"Dubs" wrote:

> Hi,
> Below is the code I am struggling with. I want to return only those
> "item_id(s)" that pertain to each member. The current results are
> giving me every "item_id" for every member.
> What am I doing wrong.
> Thanks!!!
> declare @.Indicatorgroup varchar(8000)
> select
> @.Indicatorgroup = coalesce(@.Indicatorgroup + ',','') + cast(item_id as
> varchar)
> from #temp_BLAH
> group by Member, item_id
> select +@.Indicatorgroup, Member
> from #temp_BLAH
> group by Member
> So the results now are like this:
> A,B,C,D,E....Z Smith, Ben
> A,B,C,D,E....Z Jones, Dave
> But Ben only has A, C, and D.
> So I'd like the results to be like:
> A,C,D Smith,Ben
> A,J,Q Jones,Dave
>

Need Help Coalescing

Hi,
Below is the code I am struggling with. I want to return only those
"item_id(s)" that pertain to each member. The current results are
giving me every "item_id" for every member.
What am I doing wrong.
Thanks!!!
declare @.Indicatorgroup varchar(8000)
select
@.Indicatorgroup = coalesce(@.Indicatorgroup + ',','') + cast(item_id as
varchar)
from #temp_BLAH
group by Member, item_id
select +@.Indicatorgroup, Member
from #temp_BLAH
group by Member
So the results now are like this:
A,B,C,D,E....Z Smith, Ben
A,B,C,D,E....Z Jones, Dave
But Ben only has A, C, and D.
So I'd like the results to be like:
A,C,D Smith,Ben
A,J,Q Jones,DaveHi
The safe way to do this is to use a cursor if using SQL 2000 see
http://tinyurl.com/yat5xr
John
"Dubs" wrote:
> Hi,
> Below is the code I am struggling with. I want to return only those
> "item_id(s)" that pertain to each member. The current results are
> giving me every "item_id" for every member.
> What am I doing wrong.
> Thanks!!!
> declare @.Indicatorgroup varchar(8000)
> select
> @.Indicatorgroup = coalesce(@.Indicatorgroup + ',','') + cast(item_id as
> varchar)
> from #temp_BLAH
> group by Member, item_id
> select +@.Indicatorgroup, Member
> from #temp_BLAH
> group by Member
> So the results now are like this:
> A,B,C,D,E....Z Smith, Ben
> A,B,C,D,E....Z Jones, Dave
> But Ben only has A, C, and D.
> So I'd like the results to be like:
> A,C,D Smith,Ben
> A,J,Q Jones,Dave
>

Need help changing database dynamically

I have the following code. I basically want to dynamically empty all data
from every user table in every user database. I have the code that processe
s
all the databases I want and then gets all of the tables I want. My problem
is using the GO. I can't get this to run by writing USE @.dbname GO or
USE @.dbname
GO
Does anyone have a recommendation? I'm sure I have just been looking at it
to long at this point and it is easy. Thanks in advance.
-- Sydem
begin tran ProcessDataClean
declare @.dbname varchar(255)
declare @.dbtablename varchar(255)
declare @.sql varchar(255)
DECLARE ProcessDataClean_CURSOR CURSOR FOR
select name
from master.dbo.sysdatabases
where dbid > 6 and
name not in ('pubs', 'Northwinds')
order by name
OPEN ProcessDataClean_CURSOR
FETCH NEXT FROM ProcessDataClean_CURSOR INTO @.dbname
WHILE (@.@.FETCH_STATUS <> -1)
BEGIN
IF (@.@.fetch_status <> -2)
BEGIN
select @.sql = 'USE ' + @.dbname
exec sp_sqlexec @.sql
--i want to use GO right here to switch the database
--for now i'm just printing what i want to do
PRINT ''
PRINT @.sql
PRINT 'GO'
PRINT ''
DECLARE GetDBTableName_CURSOR CURSOR FOR
select name
from dbo.sysobjects
where OBJECTPROPERTY(id, N'IsUserTable') = 1
order by name
OPEN GetDBTableName_CURSOR
FETCH NEXT FROM GetDBTableName_CURSOR INTO @.dbtablename
WHILE (@.@.FETCH_STATUS <> -1)
BEGIN
IF (@.@.fetch_status <> -2)
BEGIN
PRINT 'DELETE ' + @.dbtablename
END
FETCH NEXT FROM GetDBTableName_CURSOR INTO @.dbtablename
END
CLOSE GetDBTableName_CURSOR
DEALLOCATE GetDBTableName_CURSOR
END
FETCH NEXT FROM ProcessDataClean_CURSOR INTO @.dbname
END
CLOSE ProcessDataClean_CURSOR
DEALLOCATE ProcessDataClean_CURSOR
commit tran ProcessDataClean[USE] does not accept a parameter / variable. You will have to execute the
rest of the code inside the context where you are suing "use database_name".
Example:
exec sp_msforeachdb '
if ''?'' not in (
''master'',
''msdb'',
''model'',
''tempdb'',
''pubs'',
''northwind''
)
begin
use [?]
select
table_catalog,
table_name
from
information_schema.tables
end
'
This is an example (may be a bad one), i am not recommending to use the
undocumented and unsupported sp sp_msforeachdb.
Anyway if you try to delete from tables being referenced by other tables,
you will get an error. I think it will be better if you drop the databases
and recreate them.
AMB
"Sydem" wrote:

> I have the following code. I basically want to dynamically empty all data
> from every user table in every user database. I have the code that proces
ses
> all the databases I want and then gets all of the tables I want. My probl
em
> is using the GO. I can't get this to run by writing USE @.dbname GO or
> USE @.dbname
> GO
> Does anyone have a recommendation? I'm sure I have just been looking at i
t
> to long at this point and it is easy. Thanks in advance.
> -- Sydem
>
> begin tran ProcessDataClean
> declare @.dbname varchar(255)
> declare @.dbtablename varchar(255)
> declare @.sql varchar(255)
> DECLARE ProcessDataClean_CURSOR CURSOR FOR
> select name
> from master.dbo.sysdatabases
> where dbid > 6 and
> name not in ('pubs', 'Northwinds')
> order by name
> OPEN ProcessDataClean_CURSOR
> FETCH NEXT FROM ProcessDataClean_CURSOR INTO @.dbname
> WHILE (@.@.FETCH_STATUS <> -1)
> BEGIN
> IF (@.@.fetch_status <> -2)
> BEGIN
> select @.sql = 'USE ' + @.dbname
> exec sp_sqlexec @.sql
> --i want to use GO right here to switch the database
> --for now i'm just printing what i want to do
> PRINT ''
> PRINT @.sql
> PRINT 'GO'
> PRINT ''
> DECLARE GetDBTableName_CURSOR CURSOR FOR
> select name
> from dbo.sysobjects
> where OBJECTPROPERTY(id, N'IsUserTable') = 1
> order by name
> OPEN GetDBTableName_CURSOR
> FETCH NEXT FROM GetDBTableName_CURSOR INTO @.dbtablename
> WHILE (@.@.FETCH_STATUS <> -1)
> BEGIN
> IF (@.@.fetch_status <> -2)
> BEGIN
> PRINT 'DELETE ' + @.dbtablename
> END
> FETCH NEXT FROM GetDBTableName_CURSOR INTO @.dbtablename
> END
> CLOSE GetDBTableName_CURSOR
> DEALLOCATE GetDBTableName_CURSOR
> END
> FETCH NEXT FROM ProcessDataClean_CURSOR INTO @.dbname
> END
> CLOSE ProcessDataClean_CURSOR
> DEALLOCATE ProcessDataClean_CURSOR
> commit tran ProcessDataClean|||Correction,

> Anyway if you try to delete from tables being referenced by other tables,
> you will get an error.
Anyway, if you try to delete from tables being referenced by other tables
and there are rows related in the child table, you will get an error.
Example:
exec ('use northwind delete [dbo].[orders]')
go
AMB
"Alejandro Mesa" wrote:
> [USE] does not accept a parameter / variable. You will have to execute the
> rest of the code inside the context where you are suing "use database_name
".
> Example:
> exec sp_msforeachdb '
> if ''?'' not in (
> ''master'',
> ''msdb'',
> ''model'',
> ''tempdb'',
> ''pubs'',
> ''northwind''
> )
> begin
> use [?]
> select
> table_catalog,
> table_name
> from
> information_schema.tables
> end
> '
> This is an example (may be a bad one), i am not recommending to use the
> undocumented and unsupported sp sp_msforeachdb.
> Anyway if you try to delete from tables being referenced by other tables,
> you will get an error. I think it will be better if you drop the databases
> and recreate them.
>
> AMB
> "Sydem" wrote:
>|||Great Alejandro. I will take a look at that.
"Alejandro Mesa" wrote:
> Correction,
>
> Anyway, if you try to delete from tables being referenced by other tables
> and there are rows related in the child table, you will get an error.
> Example:
> exec ('use northwind delete [dbo].[orders]')
> go
>
> AMB
> "Alejandro Mesa" wrote:
>

Wednesday, March 28, 2012

Need help 2

Need Help 2
I am currently converting an access DB to MS SQL.
I am currently trying to figure out how to code this
I need the count of all rows in colum TERM that is > 1 when its grouped by the COLUM NAME
Anyone got any Ideas,I do not know the specifics of MS SQL, however a general approach to your problem might be

select column, count(*)
from table
where term > 1
group by student;

Need Help 2

I am currently converting an access DB to MS SQL.
I am currently trying to figure out how to code this
I need the count of all rows in colum TERM that is > 1 when its grouped by the COLUM NAME
Anyone got any Ideas,i'm not sure wheter i get it right.

hope that it was the thing that you ask for.

Select TERM,Count(<table key>) as Cnt from <Table \name>
Wher TERM > 1
Group by TERM.

If I didn't get it right then just forget about it.
:D|||select count(*) from tbl
where term in
(
select term from tbl group by name having count(*) > 1
)

Need Help - Quick simple implementation of code

Hi,
I am looking for a very simple and straighforward way of calling an already
deployed report from ASP.net. I simply need a hyperlink that displays the
report on screen if that is possible.
Any help would be tremendously appreciated.Hi Dan.
You can download this ASP.NET demo, it would help you rendering the report.
http://www.rdlcomponents.com/ASPExamples/default.aspx
Thanks
Jerry
"Dan Colgan via SQLMonster.com" wrote:
> Hi,
> I am looking for a very simple and straighforward way of calling an already
> deployed report from ASP.net. I simply need a hyperlink that displays the
> report on screen if that is possible.
> Any help would be tremendously appreciated.
>sql

Monday, March 26, 2012

Need for Multi-Threaded Visual Basic.NET to SQL Server Data Access Example Code

Of all the Visual Basic.NET data access books that I have purchased and all the Internet site example code that I have reviewed, none have had any good examples of multi-threaded VB.NET code doing data access.

I am trying to avoid the non-responsiveness in a VB app while a simple data retrieval from SQL Server 2005 is in progress.

If anyone knows of any book titles or web sites that have example code (good or not) of multi-threaded VB.NET applications doing data access against Microsoft SQL Server (7, 2000, or 2005) or even against Microsoft Access(TM), it would be very much appreciated if you could provide the book title or URL to point me in the right direction.

The more examples the better.

Thanks in advance.

Sounds like you need to make your calls Async.

http://msdn2.microsoft.com/en-us/library/ms379553(VS.80).aspx

|||

I've never seen any database programming books that cover this specific topic. You may want to start by looking for .NET books that cover multi-threaded programming in .NET. From my past experience, I remember it is a bit tricky.

|||

Async ADO.NET2.0- Summary of Best Search Results

The best discussions re async commands (transactions) using SQL Server 2005 that I have found are:

Books:

WROX?’s ‘Professional ADO.NET 2’

Web Articles :

http://msdn2.microsoft.com/en-us/vstudio/aa718334.aspx (Asych Query Samples from Data Access Samples) with source (this is the sample I chose)

www.codeproject.com/dotnet/asynchronousdataaccess.asp (with source)

http://msdn2.microsoft.com/en-us/library/ms379553.aspx (with source), but note warning at:

http://blogs.msdn.com/angelsb/archieve/2004/09/02/224964.aspx

http://nayyeri.net/archieve/2006/08/29/Asynchronous-command-execution-in-.NET-2.0.aspx

http://msdn.microsoft.com/library/en-us/cpgenref/html/cpconAsynchronousExecution.asp

http://msdn2.microsoft.com/en-us/library/ms228972(vs.80,d=printer).aspx

http://msdn2.microsoft.com/en-us/library/ms228975(VS.80).aspx

http://msdn2.microsoft.com/en-us/library/wewwczdw(VS.80).aspx

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconAsynchronousProgrammingDesignPattern.asp

|||

Most books talk about how to do basic async execution from a button click this is fine but the trouble begins when you want to populate the UI with the results of an async db command. The .NET UI is NOT thread safe and you have to serialize everything to the UI thread when doing things like updating a datagrid control for example. If you stick with the data driven events you are OK but if you want to do things more complex it can get troublesome.

I remember doing this back in the old days (.NET 1.0 and 1.1 days) and I would end up with a dead datagrid control with a big red X on it when the grid control got out of sync. So what I finally did after much pain and suffering was write my own custom message passing system that would pass messages to background threads and queue responses back to UI thread, then final bit of data manipulation had to be done on the UI thread.

I remember even creating/manipulating a new datarow on a secondary thread would break the datagrid/dataset (note I would just call NewRow on background thread and then serialize the actual adding of the new row on primary UI thread). This stuff might be fixed in .NET 2.0, so maybe I am being overly cautious here.

Wednesday, March 21, 2012

Need Comments

Can someone please give me comments to every lines to this code: (I think I know, but Iam not sure):

Dim ConnString As String = ConfigurationManager.ConnectionStrings("Connectionstring").ConnectionString

Dim strSQL As String = ("INSERT INTO Tabel3( City) VALUES ( @.City )")

Dim Conn As New SqlConnection(ConnString)

Dim Command As New SqlCommand("", Conn)

Command.CommandText = strSQL

Conn.Open()

Command.ExecuteNonQuery()

Conn.Close()

By the way, I got a question about the DetailsView in ASP.NET 2.0 (none answearing me at forums.asp.net .....:

I want to hide a <TemplateField> in Edit-mode of the Detailsview....Ive got a <hr /> in the <TemplateField> and I dont want to display it in Edit-mode...

I found this link: http://www.asp101.com/articles/sample_chapters/sitepoint_byoaspnet/chapter4.asp

Scroll down and you will see: HTMLGenericControl

There they use a <span> to change the text to another...Couldnt I use this to my issue? The different is that I have my span in a TemplateField :

<asp:TemplateField InsertVisible="false">
<ItemTemplate>
<span id="hr" runat="server"><hr /></span>
</ItemTemplate>
<HeaderTemplate><hr /></HeaderTemplate>
</asp:TemplateField>

Sub Detailsview_ModeChanged(...........)

If DetailsView1.CurrentMode = DetailsViewMode.EditThen

CType(DetailsView1.FindControl("hr"), HtmlGenericControl).InnerHtml = (" ")

End if

End Sub

I done get it to work...so Iam very appreciate for all help I can get....

Hi, here's the comments:

'Get the database connection string from the configuration
Dim ConnString As String = ConfigurationManager.ConnectionStrings("Connectionstring").ConnectionString
'SQL command to execute
Dim strSQL As String = ("INSERT INTO Tabel3( City) VALUES ( @.City )")
'Create new db connection
Dim Conn As New SqlConnection(ConnString)
'Create new command for an empty query (it would be better pass strSQL as the first param)
Dim Command As New SqlCommand("", Conn)
'Replace the empty sql query from above to the sql command we want to execute
Command.CommandText = strSQL
'Missing: The value of the @.City parameter must be set
'Connect to DB
Conn.Open()
'Execute the query
Command.ExecuteNonQuery()
'Close connection to db
Conn.Close()

Charles

|||

OK...Thank you for your commments!

But what do you mean with " It would be better pass strSQL as the first param"?

Do you mean like this: Dim Command As New SqlCommand(strSQL, Conn) ? and why would that be better?

And if I replace "" with strSQL then the comments will be like this instead?

'Create new command for an SQL query (Or what ?)
Dim Command As New SqlCommand("", Conn)
'Replace the sql query from above to the sql command we want to execute
Command.CommandText = strSQL

Here is the code that I forgott (can you please give comments here too?):

Dim City As New SqlParameter("@.City", DbType.String)

City.Value = Context.Server.HtmlEncode(tboxCity.Text)

Command.Parameters.Add(City)


|||

' Creating the City parameter as type of String

Dim City As New SqlParameter("@.City", DbType.String)

' Encoding the tboxCity.Text & assign to city.Value

City.Value = Context.Server.HtmlEncode(tboxCity.Text)

' Finally Add the City Paramerter to the Command Object

Command.Parameters.Add(City)


Need Coding for inserting data into SQL Server Using stored proecdure.

Hi to all..

I am new to ASP.Net, I want coding for inserting data in to SQL server 2005 that code contain the following criteria.

1.ASP.Net using C#.Net.

2.Using Stored Procdure.

3.the connetion string ,command , Data reader is in the same class. this class will be reusable for other page also without modifying any thing in it.

Please Help me.

Advance thanks.

Balaji,

I have an article in VB.NET which explains how to insert images to SQL server. Apart from images, i am using other columns to insert into the table.

Here is the article link:http://aspalliance.com/138_Inserting_Images_to_SqlServer_in_ASP_NET

And here is a link which will convert any VB.net code to c#http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx

Also, here is another link from ASP.NET quick starts which explains your scenario.

http://quickstarts.asp.net/QuickStartv20/aspnet/doc/data/databases.aspx#insert

Hope this helps.

|||

See if below thread can be useful.

http://forums.asp.net/t/1165758.aspx

Need code examples of how to call SSRS reports from winforms app

I'm writing a vb.net winforms app and need to call up reports from SSRS. I
also need to pass in secure parameters into the report and I don't want to
pass the credentials if I don't have to. I was hoping I could call my own
web service where I can pass encrypted data to my web service which would
contain the parameters. then a business object on the server could generate
the credential needed by SSRS and pass both the credentials and decrypted
parameters into the report. Problem is I don't know how to get the report
back to the client. One idea was to render the report on the server side
and then convert its html into a byte stream and pass the byte stream as a
return value for my web service. Then my winform client could convert the
byte stream into an html document. However, I have no idea if this is
possible and need examples for the various parts.
can someone please give me advise (and preferable links to code examples) on
how to solve this problem?
Thanks.
--
moondaddy@.nospam.nospamHello,
The following link might be helpful for you:
http://www.codeproject.com/useritems/SQLRSViewer.asp
Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
| From: "moondaddy" <moondaddy@.nospam.nospam>
| Subject: Need code examples of how to call SSRS reports from winforms app
| Date: Fri, 29 Apr 2005 00:29:02 -0500
| Lines: 22
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
| Message-ID: <ujCUetHTFHA.2756@.tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.sqlserver.reportingsvcs
| NNTP-Posting-Host: adsl-70-240-196-183.dsl.hstntx.swbell.net
70.240.196.183
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.sqlserver.reportingsvcs:42254
| X-Tomcat-NG: microsoft.public.sqlserver.reportingsvcs
|
| I'm writing a vb.net winforms app and need to call up reports from SSRS.
I
| also need to pass in secure parameters into the report and I don't want
to
| pass the credentials if I don't have to. I was hoping I could call my
own
| web service where I can pass encrypted data to my web service which would
| contain the parameters. then a business object on the server could
generate
| the credential needed by SSRS and pass both the credentials and decrypted
| parameters into the report. Problem is I don't know how to get the
report
| back to the client. One idea was to render the report on the server side
| and then convert its html into a byte stream and pass the byte stream as
a
| return value for my web service. Then my winform client could convert the
| byte stream into an html document. However, I have no idea if this is
| possible and need examples for the various parts.
|
| can someone please give me advise (and preferable links to code examples)
on
| how to solve this problem?
|
| Thanks.
|
| --
| moondaddy@.nospam.nospam
|
|
|sql

need book reccommendation

I have just accepted a new position where a new role of mine will be
managing SQL servers. I don't need to know how to write code and what have
you, just set up databases and admin type stuff. Can someone please
reccommend a book that I can read to get me familiar with terms and
procedures. I just need to develope a good understanding as quick as
possible. Thanks
Brandon Baker
A+, Net+, MCSA, MCSE
Others will have some actual text recommendations, but I firmly believe the
best reference anywhere is Books Online, which is installed as part of the
client tools along with SQL Server.
Or, you can view online here:
http://msdn.microsoft.com/library/de...start_4fht.asp
Kevin Hill
President
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"Brandon Baker" <mrmoneymatters@.nospam.postalias> wrote in message
news:OXXq5073FHA.3292@.tk2msftngp13.phx.gbl...
>I have just accepted a new position where a new role of mine will be
>managing SQL servers. I don't need to know how to write code and what have
>you, just set up databases and admin type stuff. Can someone please
>reccommend a book that I can read to get me familiar with terms and
>procedures. I just need to develope a good understanding as quick as
>possible. Thanks
> --
> Brandon Baker
> A+, Net+, MCSA, MCSE
>
|||"Brandon Baker" <mrmoneymatters@.nospam.postalias> wrote in
news:OXXq5073FHA.3292@.tk2msftngp13.phx.gbl:

> I have just accepted a new position where a new role of mine will be
> managing SQL servers. I don't need to know how to write code and what
> have you, just set up databases and admin type stuff. Can someone
> please reccommend a book that I can read to get me familiar with terms
> and procedures. I just need to develope a good understanding as quick
> as possible. Thanks
Perhaps SQL Server 2000 Administrators Companion is what you look for. At
least I'm glad to have it in my bookshelf.
Ole Kristian Bangs
MCT, MCDBA, MCDST, MCSE:Security, MCSE:Messaging
|||"Brandon Baker" <mrmoneymatters@.nospam.postalias> wrote in message
news:OXXq5073FHA.3292@.tk2msftngp13.phx.gbl...
> I have just accepted a new position where a new role of mine will be
> managing SQL servers. I don't need to know how to write code and what have
> you, just set up databases and admin type stuff. Can someone please
> reccommend a book that I can read to get me familiar with terms and
> procedures. I just need to develope a good understanding as quick as
> possible. Thanks
> --
> Brandon Baker
> A+, Net+, MCSA, MCSE
I've found this book invaluable: Microsoft SQL Server 2000 DBA Survival
Guide, Second Edition (Paperback)
by Mark Spenik, Orryn Sledge

need book reccommendation

I have just accepted a new position where a new role of mine will be
managing SQL servers. I don't need to know how to write code and what have
you, just set up databases and admin type stuff. Can someone please
reccommend a book that I can read to get me familiar with terms and
procedures. I just need to develope a good understanding as quick as
possible. Thanks
Brandon Baker
A+, Net+, MCSA, MCSEOthers will have some actual text recommendations, but I firmly believe the
best reference anywhere is Books Online, which is installed as part of the
client tools along with SQL Server.
Or, you can view online here:
http://msdn.microsoft.com/library/d...r />
_4fht.asp
Kevin Hill
President
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"Brandon Baker" <mrmoneymatters@.nospam.postalias> wrote in message
news:OXXq5073FHA.3292@.tk2msftngp13.phx.gbl...
>I have just accepted a new position where a new role of mine will be
>managing SQL servers. I don't need to know how to write code and what have
>you, just set up databases and admin type stuff. Can someone please
>reccommend a book that I can read to get me familiar with terms and
>procedures. I just need to develope a good understanding as quick as
>possible. Thanks
> --
> Brandon Baker
> A+, Net+, MCSA, MCSE
>|||"Brandon Baker" <mrmoneymatters@.nospam.postalias> wrote in
news:OXXq5073FHA.3292@.tk2msftngp13.phx.gbl:

> I have just accepted a new position where a new role of mine will be
> managing SQL servers. I don't need to know how to write code and what
> have you, just set up databases and admin type stuff. Can someone
> please reccommend a book that I can read to get me familiar with terms
> and procedures. I just need to develope a good understanding as quick
> as possible. Thanks
Perhaps SQL Server 2000 Administrators Companion is what you look for. At
least I'm glad to have it in my bookshelf.
Ole Kristian Bangs
MCT, MCDBA, MCDST, MCSE:Security, MCSE:Messaging|||"Brandon Baker" <mrmoneymatters@.nospam.postalias> wrote in message
news:OXXq5073FHA.3292@.tk2msftngp13.phx.gbl...
> I have just accepted a new position where a new role of mine will be
> managing SQL servers. I don't need to know how to write code and what have
> you, just set up databases and admin type stuff. Can someone please
> reccommend a book that I can read to get me familiar with terms and
> procedures. I just need to develope a good understanding as quick as
> possible. Thanks
> --
> Brandon Baker
> A+, Net+, MCSA, MCSE
I've found this book invaluable: Microsoft SQL Server 2000 DBA Survival
Guide, Second Edition (Paperback)
by Mark Spenik, Orryn Sledge

need book reccommendation

I have just accepted a new position where a new role of mine will be
managing SQL servers. I don't need to know how to write code and what have
you, just set up databases and admin type stuff. Can someone please
reccommend a book that I can read to get me familiar with terms and
procedures. I just need to develope a good understanding as quick as
possible. Thanks
--
Brandon Baker
A+, Net+, MCSA, MCSEOthers will have some actual text recommendations, but I firmly believe the
best reference anywhere is Books Online, which is installed as part of the
client tools along with SQL Server.
Or, you can view online here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/startsql/getstart_4fht.asp
--
Kevin Hill
President
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"Brandon Baker" <mrmoneymatters@.nospam.postalias> wrote in message
news:OXXq5073FHA.3292@.tk2msftngp13.phx.gbl...
>I have just accepted a new position where a new role of mine will be
>managing SQL servers. I don't need to know how to write code and what have
>you, just set up databases and admin type stuff. Can someone please
>reccommend a book that I can read to get me familiar with terms and
>procedures. I just need to develope a good understanding as quick as
>possible. Thanks
> --
> Brandon Baker
> A+, Net+, MCSA, MCSE
>|||"Brandon Baker" <mrmoneymatters@.nospam.postalias> wrote in
news:OXXq5073FHA.3292@.tk2msftngp13.phx.gbl:
> I have just accepted a new position where a new role of mine will be
> managing SQL servers. I don't need to know how to write code and what
> have you, just set up databases and admin type stuff. Can someone
> please reccommend a book that I can read to get me familiar with terms
> and procedures. I just need to develope a good understanding as quick
> as possible. Thanks
Perhaps SQL Server 2000 Administrators Companion is what you look for. At
least I'm glad to have it in my bookshelf.
--
Ole Kristian Bangås
MCT, MCDBA, MCDST, MCSE:Security, MCSE:Messaging|||"Brandon Baker" <mrmoneymatters@.nospam.postalias> wrote in message
news:OXXq5073FHA.3292@.tk2msftngp13.phx.gbl...
> I have just accepted a new position where a new role of mine will be
> managing SQL servers. I don't need to know how to write code and what have
> you, just set up databases and admin type stuff. Can someone please
> reccommend a book that I can read to get me familiar with terms and
> procedures. I just need to develope a good understanding as quick as
> possible. Thanks
> --
> Brandon Baker
> A+, Net+, MCSA, MCSE
I've found this book invaluable: Microsoft SQL Server 2000 DBA Survival
Guide, Second Edition (Paperback)
by Mark Spenik, Orryn Sledge

Monday, March 19, 2012

Need an example of a trigger.

Hello,

I'm a newbie to the MS SQL db engine, and I'd like to have some help with Transact-SQL. I'd like to know the code to create a trigger to do the following. I have two tables, one references the other. I'd like the database to automatically delete the records from table2 when the record that they reference in table1 is deleted. Much thanks.Try this

create trigger dbo.trigger_deleterecs on table1
for delete
as
begin

declare @.refcolumn datatypehere
select @.refcolumn = deleted.refcolumn from deleted
delete from table2 where table2refcolumn = @.refcolumn

end|||how about:

create trigger dbo.trigger_deleterecs on table1
for delete
as
begin
delete from table2 where refcolumn in (select refcolumn from deleted)
end

or

create trigger dbo.trigger_deleterecs on table1
for delete
as
begin
delete t2
from table2 t2
join deleted d on t2.refcolumn = d.refcolumn
end

by using either of these you will delete all records when multipule records are deleted.

Need all rows within each group to be shown on 1 page

Hi,

I have data that is grouped by a code number. One of the code numbers have over 600 rows, while other code numbers have around 10 to 20 rows within it.

When I run the report the code number that has over 600 rows gets split over 2 pages while the other code numbers each get their own page.

How do I make it so that when I run the report the code number that has over 600 rows gets all displayed on the 1 page instead of being split over 2?

Thanks

Ben.

can anyone help please?|||

Hi ben22,

I'm afraid there is not really a functionality in Reporting Services that does this. I know this is a lack in Reporting Services.

Greetz,

Geert

Geert Verhoeven
Consultant @. Ausy Belgium

My Personal Blog

|||

Hi Ben

Do you just want it to display on 1 page in the browser or
do you require this for printing aswell?

If it is for viewing purposes only, you can try to set the
'Interactive Page size' in the report properties to have a higher width.

G

|||need it both for display in the browser and for printing, as when it gets exported to excell it needs to be in the same sheet instead of being expanded over 2. This is because a certain value in the row gets summed at the end and I need that sum to include all the rows within the group, as when it splits over 2 pages I get two different sums where they should be altogether.|||

Hi ben,

As mentioned before, it is not possible to make the page size dynamic for printing and viewing at the same time.

You mentioned that you receive 2 sum results. It is possible to only have only a total line at the end in case of on each page.

For example:
When you use a Table you can set the total in the Table footer. Even if the table overlaps multiple pages, it will only be displayed at the last page.

Greetz,

Geert

Geert Verhoeven
Consultant @. Ausy Belgium

My Personal Blog

|||

Sorry, I should of explain things a bit better before. By groups I meant I have 1 group in the table. This group breaks the data up by the unique field assigned to each data item and uses a group footer to do the sum. For example:

I have 800 cars, 600 are red 100 are blue and 100 are green. So when I run the report is looks like this

Page 1

RED

Name | Model | Price

Car1 | c1 | 20000

Car2 | c2 | 30000

…

Car400 | c400 | 15000

-

Total Price: 3000000

Page 2

RED

Name | Model | Price

Car401 | c401 | 20000

Car402 | c402 | 30000

…

Car600 | c600 | 15000

-

Total Price: 1500000

Page 3

BLUE

Name | Model | Price

Car1 | c1 | 10000

Car2 | c2 | 30000

…

Car100 | c100 | 40000

-

Total Price: 1000000

Page 4

GREEN

Name | Model | Price

Car1 | c1 | 25000

Car2 | c2 | 17000

…

Car100 | c100 | 40000

-

Total Price: 1200000

As you can see there are 4 pages. It splits the RED cars up over 2 pages giving the 2 different sums ie: cars 1 – 400 with the sum 3000000 and then cars 401 – 600 with the sum 1500000. I want my report to work so that the RED cars are all together and not on different pages, so altogether there are only 3 pages. So to look like this:

Page 1

RED

Name | Model | Price

Car1 | c1 | 20000

Car2 | c2 | 30000

…

Car600 | c600 | 15000

-

Total Price: 4500000

Page 2

BLUE

Name | Model | Price

Car1 | c1 | 10000

Car2 | c2 | 30000

…

Car100 | c100 | 40000

-

Total Price: 1000000

Page 3

GREEN

Name | Model | Price

Car1 | c1 | 25000

Car2 | c2 | 17000

…

Car100 | c100 | 40000

-

Total Price: 1200000

|||

Hi,

It is not possible to force a group on 1 page but it is possible to have only 1 total per group. You need to set the Color field in the expresion of the group. When you then look at the group footer, you will see that the total is done on group base.

Greetz,

Geert

Geert Verhoeven
Consultant @. Ausy Belgium

My Personal Blog

|||

Geert Verhoeven wrote:

It is not possible to force a group on 1 page but it is possible to have only 1 total per group. You need to set the Color field in the expresion of the group. When you then look at the group footer, you will see that the total is done on group base.

Sorry but I dont really understand what you have said or how to implement it

|||

Hi,

What I mean is that you can not force the contents of a group to be on 1 page. Although the problem you have that the total is displayed on each page can be avoided by using the footer of the group. When you set the total in the group of the footer, only at the end of the group a total will be displayed and not at the end of each page.

Hope this is more clear.

Greetz,

Geert

Geert Verhoeven
Consultant @. Ausy Belgium

My Personal Blog

|||im using a group a footer and it still displays the total at the end of each page, not at the end of the group

Wednesday, March 7, 2012

Need a list of Error Code

Hi,

When we configure a transformation to redirect the error record, SSIS gives 2 columns: 'error code' and 'error column'. In one article, I have seen how to get the error description using the 'error code'.

My questions are,

    Where I can get list of all possible error codes? 'error column' gives the id of the column. How to get the name of the 'error column'?

Thanks.

Basically you need to know the metadata of the normal output, not that easy, but simon has wrapped this up in a Tx.

http://sqljunkies.com/WebLog/simons/archive/2005/12/15/SSIS_Enhanced_Error_Component.aspx

Some related info -

http://msdn2.microsoft.com/en-us/library/ms345163.aspx

The SSIS error codes are listed in BOL. I also have them on my wiki, because BOL only got them in an update and I wanted them before that, and also you can add notes on the errors on the wiki.