Showing posts with label dbo. Show all posts
Showing posts with label dbo. Show all posts

Friday, March 30, 2012

How To Script

I need to update a value in IMA_GLInvAcctNbr from 11283 to 11500. the table
name is dbo.item. What would my script look like to do this in SQL server
2005? The column has a silver key by it too in SQL Server Management
Studio.

ThanksBrian (b.houghtby@.eaglecrusher.com) writes:

Quote:

Originally Posted by

I need to update a value in IMA_GLInvAcctNbr from 11283 to 11500. the
table name is dbo.item. What would my script look like to do this in
SQL server 2005? The column has a silver key by it too in SQL Server
Management Studio.


UPDATE dbo.item
SET IMA_GLInvAcctNbr = 11500
WHERE IMA_GLInvAcctNbr = 11283

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||What does the silver key mean?

"Erland Sommarskog" <esquel@.sommarskog.sewrote in message
news:Xns9947EFB6764B9Yazorman@.127.0.0.1...

Quote:

Originally Posted by

Brian (b.houghtby@.eaglecrusher.com) writes:

Quote:

Originally Posted by

>I need to update a value in IMA_GLInvAcctNbr from 11283 to 11500. the
>table name is dbo.item. What would my script look like to do this in
>SQL server 2005? The column has a silver key by it too in SQL Server
>Management Studio.


>
UPDATE dbo.item
SET IMA_GLInvAcctNbr = 11500
WHERE IMA_GLInvAcctNbr = 11283
>
>
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
>
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

|||What does the silver key mean?

It means that it is in a foreign key relationship to another table.

On Jun 7, 9:51 am, "Brian" <b.hough...@.eaglecrusher.comwrote:

Quote:

Originally Posted by

>
"Erland Sommarskog" <esq...@.sommarskog.sewrote in message
>
news:Xns9947EFB6764B9Yazorman@.127.0.0.1...
>
>
>

Quote:

Originally Posted by

Brian (b.hough...@.eaglecrusher.com) writes:

Quote:

Originally Posted by

I need to update a value in IMA_GLInvAcctNbr from 11283 to 11500. the
table name is dbo.item. What would my script look like to do this in
SQL server 2005? The column has a silver key by it too in SQL Server
Management Studio.


>

Quote:

Originally Posted by

UPDATE dbo.item
SET IMA_GLInvAcctNbr = 11500
WHERE IMA_GLInvAcctNbr = 11283


>

Quote:

Originally Posted by

--
Erland Sommarskog, SQL Server MVP, esq...@.sommarskog.se


>

Quote:

Originally Posted by

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...downloads/books...
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ons/books.mspx- Hide quoted text -


>
- Show quoted text -

Monday, March 26, 2012

how to run this proc in SQL Analyzer?

hi, guys

I have a stored procedure, like that:

CREATE PROCEDURE [dbo].[ViewTitles]
@.UID int,
@.DateStart datetime,
@.DateEnd datetime,
........

When I run this query in SQL Analyzer like this:
ViewTitles 6165, '2006-01-29 10:00:00', '2006-02-29 10:00:00'

It alwasy shows:
Error converting data type varchar to datetime.

If I run it in code, asp.net, or report, no problem at all.
What is wrong with that?

Thanks.

What is the dateformat of the session when logged in through ISQLW? You can verify this by looking at output of DBCC USEROPTIONS. Look for set option "dateformat". In addition to this, you should one of the ISO 8601 formats for datetime literals that should be interpreted correctly irrespective of the language or dateformat settings. Specify the value instead like '2006-01-29T10:00:00'.

Friday, March 23, 2012

How to run query between two databases

Hi i have query which i need to join it
like i am doing some thing like
Select [a].[dbo].[tbla].* From [a].[dbo].[tbla] INNER INNER JOIN
[B].[dbo].[tblB ON [a].[dbo].[tbla].[ID] =
[b].[dbo].[tbla].[ID]
and i am running that query in database A but the only problem is it saying
that b.dbo.tblb.ID is invalid colum name i dont understand that i am giving
full address of both databases but cannt do it ..... any help thanksYour query seem to be syntactically wrong.
Anyways, correct it and try to add table alias for the tables and use them
to refer to the columns.
Or post the actual query that gave the error you mentioned.
--
"amjad" wrote:

> Hi i have query which i need to join it
> like i am doing some thing like
> Select [a].[dbo].[tbla].* From [a].[dbo].[tbla] INNER INNER JOIN
> [B].[dbo].[tblB ON [a].[dbo].[tbla].[ID] =
> [b].[dbo].[tbla].[ID]
> and i am running that query in database A but the only problem is it sayin
g
> that b.dbo.tblb.ID is invalid colum name i dont understand that i am givin
g
> full address of both databases but cannt do it ..... any help thanks|||could you post what your actually doing, rather than something like
what you're doing?
I mean what's an INNER INNER JOIN? is it something that's really
seriously inner on the join? and is it a typo or have you missed out a
"]" in your actual code?|||thanks for help i solved thanks
"Will" wrote:

> could you post what your actually doing, rather than something like
> what you're doing?
> I mean what's an INNER INNER JOIN? is it something that's really
> seriously inner on the join? and is it a typo or have you missed out a
> "]" in your actual code?
>

Wednesday, March 21, 2012

How to run DTS from stored proc

I am running a DTS package from stored proc as,

Exec [master].[dbo].[xp_cmdshell] "dtsrun /S Server /U User /P Pass /N Package Name"

But i am getting an error :

The system can not find the path specified.

But i am able to run the same from DTS Design Wizard.

Please anyone of you help me out.set @.str varchar(8000)
set @.dtsname varchar(8000)
set @.dtsname=physical path and name of your dts package
SET @.str='DtsRun '+ '/F ' + @.DTSNAME

EXEC master..xp_Cmdshell @.str


I believe it will help you

Subhasish Ray

subhasishray@.sify.com

Monday, March 12, 2012

How to return a Table to VS using Stored Procedure

i have a Stored Procedure like below but it can't seem to return any table to Visual Studio

Code Snippet

ALTER PROCEDURE dbo.SelectHWCategoryBased

(
@.title varchar /* Like Processor/RAM */
)

AS

SELECT Hardwares.HWID, Hardwares.Title
FROM Hardwares INNER JOIN
Category ON Hardwares.CategoryID = Category.CategoryID
WHERE (Category.Type LIKE '%Hardware%') AND (Category.Title = @.Title)


There is no issue on your SP.

You have to use the SQLDataAdapater to fill the dataset. Use the current command object as SelectCommand of the Adapter & call the Fill() method.. Check with ADO.NET forum

|||

@.title varchar /* Like Processor/RAM */

The default size for an incoming varchar parameter is one character. If your incoming parameter value is longer than one character, it is being truncated, and the WHERE clause is looking for a Category.Title that matches the single character.

Probably won't find one.

Change the parameter to varchar(n) -n being sized appropriate to your Title field.

|||Thanks, that works, missed out that.

Friday, March 9, 2012

how to retrive a SP table inside a SP?

Hello, inside of my SP i want to execute another SP, something like:

EXEC

[dbo].[Forum_DeleteBoard] @.BoardID= @.DelBoardID

this function Forum_DeleteBoard returs one row with 3 columns as a table, how do i get the first column of that table into a variable so i can check if it was ok or not
(it returns just one row with 3 columns).

Columns it returns:
QResult , Threads , Answers

SELECT @.isok = QResult FROM EXEC [dbo].[Forum_DeleteBoard] @.BoardID= @.DelBoardID ?

or how do you get it?

Patrick

you can try to do it by creating temp table and next by do insert from your stored procedure into this temp table. Temp table have to have the same layout as returned table. and you can select value you need from this table.

If you can modify your second procedure try to modify it to return output parameters instead of table result set. It will be simple and much faster.

You can find information about both solutions in SQL help, but if you have a problem with it just post again.

Thanks