Showing posts with label return. Show all posts
Showing posts with label return. Show all posts

Monday, March 19, 2012

Can MSSQL load a tab delimited text file?

Hi all...

I would like to know if SQL SERVER can load a tab delimited text file.

If yes, how?

A search on the web did not return me the "load data" command as mysql
or other.

Thank you all.BULK INSERT|||Oh my god...

Why you say it is a bulk insert man?? Come on...

I am a MySQL user and wants to know if i can load my data on MSSQL
without a need of a converter.|||<joealey2003@.yahoo.com> wrote in message
news:1117271736.412801.299580@.f14g2000cwb.googlegr oups.com...
> Oh my god...
> Why you say it is a bulk insert man?? Come on...
> I am a MySQL user and wants to know if i can load my data on MSSQL
> without a need of a converter.

I'm not sure what you don't like about his answer. Did you even bother to
look up the command he gave you?
|||Don't you have Books Online available? I expect Q. John Chen assumed you
would lookup the command:
http://msdn.microsoft.com/library/d...asp?frame=true

--
David Portas
SQL Server MVP
--

<joealey2003@.yahoo.com> wrote in message
news:1117271736.412801.299580@.f14g2000cwb.googlegr oups.com...
> Oh my god...
> Why you say it is a bulk insert man?? Come on...
> I am a MySQL user and wants to know if i can load my data on MSSQL
> without a need of a converter.|||Oh...

So Bulk Insert is the command...

Thank you all...

Saturday, February 25, 2012

Can I use if statement in a table valued function?

hi,

I am using a function in sql server 2005 like this:

...... myfunction(... @.FlagOn int)

.......

begin

return

(

if(@.FlagOn = 1)

select * from.......

else

select * form....

)

end

But it keeps complaining there is some syntax error around if. What is it?

Thanks.

No. Table valued function won’t allow this. Because it might cause more than one schema definition for the table valued function, which is not possible in the database.

If it is a filter then you can attach the additional condition on the where clause. If the flag is used to fetch different columns or different table create new function for each flag.

If the final schema is same (same number of columns and identical datatype for both the flags), use table valued function (not inline table valued function).

Code Snippet

Create function getvalues(@.flag as int)

Returns @.result table (id int, name varchar(100))

As

Begin

If @.flag=1

Insert into @.result

Select Top 10 id, name from sysobjects

Else

Insert into @.result

Select Top 10 id,name from syscolumns

return;

End

Go

Select * from getvalues(1)

go

Select * from getvalues(0)

|||

Thanks lot, it works great.

Another thing is, can I create index on table @.result?

Coz I am thinking something like this:

select * from getvalues(1) as s where s.ID > 100

If it has index on ID, it might be faster.

|||

Maximum you can add Primary Key/Unique key on the table variable. If your values are unique then you can go for it.

@.result table (id int primary key, name varchar(100))

Thursday, February 16, 2012

can I return output from stored procedure into an HTA to display in browser?

Hi all. I have a stored procedure on my sql server that returns a
simple informtation about that tim a database was backed up. I owuld
like to create an HTA that operator types can look at to make sure
that the backups finished, can someone help me do this?

The stored procedure in called sp_lastback and the output looks like
this:

database days since backup timestamp of backup
dbase1 0 2004-10-14 00:41:21.000
dbase2 0 2004-10-14 00:08:36.000
dbase3 1 2004-10-13 22:46:57.000

Can this be done? If someone could help me with this simple problem, I
could probably reuse the same method a 100 useful ways.

Thanks in advance!"sumGirl" <emebohw@.netscape.net> wrote in message
news:a5e13cff.0410141529.23a19fd8@.posting.google.c om...
> Hi all. I have a stored procedure on my sql server that returns a
> simple informtation about that tim a database was backed up. I owuld
> like to create an HTA that operator types can look at to make sure
> that the backups finished, can someone help me do this?
> The stored procedure in called sp_lastback and the output looks like
> this:
> database days since backup timestamp of backup
> dbase1 0 2004-10-14 00:41:21.000
> dbase2 0 2004-10-14 00:08:36.000
> dbase3 1 2004-10-13 22:46:57.000
> Can this be done? If someone could help me with this simple problem, I
> could probably reuse the same method a 100 useful ways.
> Thanks in advance!

You'll probably get a better response in a group for HTA users. I guess you
could write a client script to execute the procedure with ADO, then loop
over the ResultSet and build the .hta file dynamically, but I have no idea
about any details.

Simon|||Here's a generic technique to render a resultset using dynamic html. There
may be better ways to accomplish the task, though.

<html>
<head>
<body>
<Script Language="VBScript"
Sub btnListBackups_OnClick()

Set oConnection = CreateObject("ADODB.Connection")

oConnection.Open "Provider=SQLOLEDB" & _
";Data Source=" & "DBDELTA1" & _
";Integrated Security=SSPI"

Set recordSet = oConnection.Execute("EXEC tempdb..sp_lastback")
myResultTable = "<table border=""1"">"
myResultTable = myResultTable & "<tr>"
For i = 0 To recordSet.Fields.Count - 1
myResultTable = myResultTable & _
"<th>" & _
recordSet.Fields(i).Name & _
"</th>"
Next
myResultTable = myResultTable & "</tr>"
Do While Not recordSet.EOF
myResultTable = myResultTable & "<tr>"
For i = 0 To recordSet.Fields.Count - 1
myResultTable = myResultTable & _
"<td>" & _
recordSet.Fields(i).Value & _
"</td>"
Next
myResultTable = myResultTable & "</tr>"
recordSet.MoveNext
Loop
myResultTable = myResultTable & "</table>"
recordSet.Close
oConnection.Close

Results.innerHTML = myResultTable
End Sub

</script
<input type="button" id="btnListBackups" value="List Backups">
<hr>
<nobr Id=Results></nobr>
</body>
</html
--
Hope this helps.

Dan Guzman
SQL Server MVP

"sumGirl" <emebohw@.netscape.net> wrote in message
news:a5e13cff.0410141529.23a19fd8@.posting.google.c om...
> Hi all. I have a stored procedure on my sql server that returns a
> simple informtation about that tim a database was backed up. I owuld
> like to create an HTA that operator types can look at to make sure
> that the backups finished, can someone help me do this?
> The stored procedure in called sp_lastback and the output looks like
> this:
> database days since backup timestamp of backup
> dbase1 0 2004-10-14 00:41:21.000
> dbase2 0 2004-10-14 00:08:36.000
> dbase3 1 2004-10-13 22:46:57.000
> Can this be done? If someone could help me with this simple problem, I
> could probably reuse the same method a 100 useful ways.
> Thanks in advance!|||Thanks Dan! Thats exactly the kind of example I can run with!

Can I return a value in a variable from a SSIS program back to C# after the SSIS program is run

Can I return a value in a variable from a SSIS program back to C# after the SSIS program is run from C#?Yes - you can use the variables property of the Package object: http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.dtscontainer.variables.aspx

can I return a message from SQL Server to C# application?

I am using SQL server in my C# application and I was thinking if there is any way to return a message from the SQL Server directly to the MessageBox.Show

Right now I am using RETURN 999 and sending the value to C# then implementing and IF return_value = 999 the MessageBox.Show

You could use an OUTPUT parameter and return any varchar()/string message you desire.

I think that it would be difficult to return a message back directly from SQL Server to a messagebox control's show event. However, you could explore setting up a Delegate and a CallBack routine that could accomplish your desired results.

You may wish to post your issue on one of the WinForms forums, where you are more likely to get the help needed.