it’s worked but I want insert space with number into database.
Id
Separate
Number
1
2016_03_30
2
3
4
5
6
7
8
9
10
11
12
For example if id length == 1 then before number need three
space " 1"
if id length == 2 then before number need two space " 10"
if id length == 3 then before number need two space " 100"
how I can insert space and number from dataagridview into database?
Hi,
Please refer below sql
SQL
DECLARE @Id VARCHAR(50) SET @Id = 1; SELECT @Id = REPLACE(STR(@Id, 3), SPACE(1), '0') SELECT @Id SELECT @Id = REPLACE(STR(@Id, 3), SPACE(1), ' ') SELECT @Id
Here I have shown for 0 and space as well
Output
001
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.