|
How do you think this will work? First of all, you are connecting to SQL Server here, secondly the strupdate command is wrong. Finally, always use parameterized queries as they are much better.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi All,
How do i get week of a month?
somthing like ....
Datename(week,getdate())
Can you please help?
Thanks
kibrom
|
|
|
|
|
select datediff(week,'2007.09.01',getdate())
it return value 2 which means it is second week from given date
I Love SQL
|
|
|
|
|
|
Months don't have weeks, years have weeks. At least that seems to be what ISO says.
|
|
|
|
|
SELECT CAST(DATEPART(wk,getdate())-DATEPART(wk,DATEADD(dd, -(DATEPART(dd, GETDATE()) - 1), GETDATE()))+1 as varchar)
|
|
|
|
|
Hi,i want to know that how can i get schedule back up from server to local ??
for example :
i have a database ("testDB")in the server ( www.server.com) then i need get backup every day and transfer all new data to my PC in (localhost ).
thanks.
|
|
|
|
|
objsqlconn=new sqlconnection("user id=sa;password=;data source=servername")
objsqlconn.open
objsqlcmd=new sqlcommand
objsqlcmd.connection=objsqlconn
objsqlcmd.commandtext="master..xp_cmdshell 'del d:\" + databasename + "'"
objsqlcmd.commandtype=commandtype.text
objsqlcmd.executenonquery
objsqlcmd.commandtext=" backup database " + databasename + " to disk='" + databasename + "'"
objsqlcmd.commandtype=commandtype.text
objsqlcmd.executenonquery
this is coding to backup of database from the server
|
|
|
|
|
I have a string of hex characters "0x89504e". I convert this to a string of binary characters @sOutput = "100010010101000001001110". I then run SELECT CAST(@sOutput AS BINARY). This returns me "0x313030303130303130313031303030303031303031313130000000000000".
How would I go about converting the string to binary such that the value would return as the original "0x89504e"? It's looking like the CAST is treating the string as numeric and converting a really large int to binary.
|
|
|
|
|
SELECT CONVERT(varbinary(20), 'stringValue')
I Love SQL
|
|
|
|
|
sonal dadhania1 wrote: It's looking like the CAST is treating the string as numeric and converting a really large int to binary
It is treating the string as a string and converting it in to its ASCII codes.
I don't use binary data types much, but the following works:
DECLARE @hex AS VARBINARY(10)
SET @hex = 0x89504e
SELECT @hex
NOTE: There are no quotes/apostrophes around the hex value.
If you are coming from an application, use varbinary parameters and pass the value to the paramter as a byte array (byte[] )
|
|
|
|
|
Hi all,
I have a function called fnGetOrderItemPriceDummy, which takes two parameters, such as @OrderID & @chord. I was trying to execute this function in our linked server, and it fired error. My code follows.....
(Select * from Openquery([linkedserver],'select myserver.dbo.fnGetOrderItemPriceDummy ( '+ Convert(varchar(50) ,@OrderID)+' , '''''+ @chord+''''')) .
Can anyone say where is my mistake....
Thanks for your time.....
Sebastian
|
|
|
|
|
I don't know syntax of OPENQUERY command, but I am sure that you are missing a database name here:
select myserver.DATABASE.dbo.fnGetOrderItemPriceDummy
|
|
|
|
|
I have these tables
Customer Table:
CustomerID int; PK
FirstName nvarchar;
LastNaem nvarchar;
etc.;
Products Table:
ProductID int; PK
Name varcahr;
etc.;
OrderItems Table:
OrderItemID int; PK
ProductID int; FK
CustomerID int; FK
etc.;
Now I would like to get all users that have ordered: Product1 AND Product2, etc.
Only those people that orders all the selected products
-- modified at 21:15 Monday 10th September, 2007
|
|
|
|
|
Pass @Products --> with comma separated values like 'product1,product2'
and no of items @ProductCount --> 2
Select * from Customers Where CustomerID in
(Select CustomerID From
(Select CustomerID from OrderItems Inner Join Products on Products .ProductID = OrderItems.productid
Where [Name] IN (@products)
Group by CustomerID,[Name]) as Temp
Group by CustomerID having Count(CustomerID) = @productCount)
Best Regards,
Chetan Patel
|
|
|
|
|
This can't possibly work, can it?
I mean, the WHERE [Name] IN (@Products) part specifically.
|
|
|
|
|
If this has to work then the query should get execute using "EXEC sp_executesql " command
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
You could create the inner query like this:
SELECT oi.CustomerID
FROM OrderItems oi
JOIN Products p
WHERE p.ProductID IN ('Product1', 'Product2')
GROUP BY oi.CustomerID
HAVING COUNT(*) = 2
You'll have to dynamically create the WHERE p.ProductID IN (...) part, and the value for the HAVING COUNT(*) = 2 should use a parameter.
Joined with the customer table, the results could look something like this:
DECLARE @NumberOfProducts int
SET @NumberOfProducts = 2
SELECT
c.*
FROM Customer c
JOIN
(
SELECT oi.CustomerID
FROM OrderItems oi
JOIN Products p
WHERE p.ProductID IN ('Product1', 'Product2')
GROUP BY oi.CustomerID
HAVING COUNT(*) = @NumberOfProducts
) AS t
ON t.CustomerID = c.CustomerID
|
|
|
|
|
|
Notify when a special partition in analysis service must update?
how i can triger a program to update a special partition of a cube at a required time?
or
how to found a way to know if a special partition need to be update?
thanks
|
|
|
|
|
when you want to connect to the db in the server do i have to use sqloledb provider , can't i use sqlclient provider.
|
|
|
|
|
http://wwww.connectionstrings.com
I Love SQL
|
|
|
|
|
you want to add port on firewall port number = 1433 to you can use sqlclient
Rami Abdalhalim
|
|
|
|
|
sqlclient uses a an ole connection and you can use to connect it to SQL Server, this is the prefered method and is used in most examples.
|
|
|
|
|
dear friends,
I develop an Win application by using MS Access.I have got a problem in SQL statement.I have got a form that has
got 2 ComboBox and a DataGridView.The name of the first is cmbCategories and the second one is cmbContent.Content
is listing the content of categories.I use an array to transfer letters when I choose the category in
cmbCategories as it is Alphabetical Array.When I choose a letter from cmbContent like A,B or another one,but no
records is listing in the DataGridView.I try to use "Like" statement for this action.It is like this:
string strSQL = "select FilmName from films where FilmName like" + "'" + cmbContent.Text + "*'";
cmbContent has got the Alphabetical letters by sequence.I want to list the FilmName that is beginning as
alphabetic.For example,when I choose letter A,the films begins A must be listed.Does anybody help me?Thanks for
your help.
|
|
|
|